net.sf.navigator.taglib
Class DisplayMenuTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by net.sf.navigator.taglib.DisplayMenuTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
DisplayMenuTag

public class DisplayMenuTag
extends javax.servlet.jsp.tagext.TagSupport

The major behavior of this tag is to set the value for the usage in the HTML hyperlink 'href' attribute. The value is determined by the following attributes defined in menu-config.xml, in this prioritize order: 'location', 'page', 'forward', 'action'.

You can now define a 'forward' or 'action' attribute in the <Item> element in your menu-config.xml. The 'action' attribute takes the value of a Logical Struts Action name for which to look up the context-relative URI. The resultant URI will carry the Context Path (if any), Module Prefix (if any), Session ID (if any), and Servlet Mapping (path mapping or extension mapping). Here is an example:

 <Menu name="indexMenuMore" title="More Examples">
   <Item name="actionExample"  title="Example - 'action' attribute"
         action="/menu/bullet"/>
   <Item name="pageExample" title="Example - 'page' attribute"
         page="/bulletmenu.jsp"/>
 </Menu>
 

Version:
$Revision: 1.23 $ $Date: 2006/10/22 07:16:39 $
Author:
ssayles, mraible
See Also:
Serialized Form

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
DisplayMenuTag()
           
 
Method Summary
 int doStartTag()
           
protected  String getPage(String page)
          Returns the value with page prepended with a "/" if it is not already.
 void release()
           
protected  void setLocation(MenuComponent menu)
           
 void setName(String name)
           
protected  void setPageLocation(MenuComponent menu)
          Sets the value for the menu location to the appropriate value if location is null.
 void setTarget(String target)
           
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

DisplayMenuTag

public DisplayMenuTag()
Method Detail

setName

public void setName(String name)

setTarget

public void setTarget(String target)

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException

setPageLocation

protected void setPageLocation(MenuComponent menu)
                        throws MalformedURLException,
                               javax.servlet.jsp.JspException
Sets the value for the menu location to the appropriate value if location is null. If location is null, and the page attribute exists, it's value will be set to the the value for page prepended with the context path of the application. If the page is null, and the forward attribute exists, it's value will be looked up in struts-config.xml. FIXME - ssayles - 121102 Ideally, this should happen at menu initialization but I was unable to find a reliable way to get the context path outside of a request. The performance impact is probably negligable, but it would be better to check for this only once.

Parameters:
menu - The menu component to set the location for.
Throws:
MalformedURLException
javax.servlet.jsp.JspException

setLocation

protected void setLocation(MenuComponent menu)
                    throws MalformedURLException
Throws:
MalformedURLException

getPage

protected String getPage(String page)
Returns the value with page prepended with a "/" if it is not already.

Parameters:
page - The value for the page.

release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport


Copyright © 2003-2007 SourceForge. All Rights Reserved.