net.sourceforge.stripes.tag
Class LinkTagSupport

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
          extended by net.sourceforge.stripes.tag.LinkTagSupport
All Implemented Interfaces:
DynamicAttributes, JspTag, Tag, ParameterizableTag
Direct Known Subclasses:
LinkTag, UrlTag

public abstract class LinkTagSupport
extends HtmlTagSupport
implements ParameterizableTag

Abstract support class for generating links. Used by both the LinkTag (which generates regular <a href=""/> style links) and the UrlTag which is a rough similie of the JSTL url tag.

Since:
Stripes 1.4
Author:
Tim Fennell

Field Summary
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
LinkTagSupport()
           
 
Method Summary
 void addParameter(String name, Object valueOrValues)
          Used by stripes:param tags (and possibly other tags at some distant point in the future) to add a parameter to the parent link tag.
protected  String buildUrl()
          Builds the URL based on the information currently stored in the tag.
 void clearParameters()
          Clears all existing parameters.
 String getAnchor()
          Gets the anchor element that is appended at the end of the URL.
 Object getBeanclass()
          Gets the bean class (String FQN or Class) to generate a link for.
 String getEvent()
          Gets the (optional) event name that the link will trigger.
 Map<String,Object> getParameters()
          Retrieves the parameter values set on the tag.
protected  String getPreferredBaseUrl()
          Returns the base URL that should be used for building the link.
 String getUrl()
          Gets the URL that is supplied by the user/developer on the page.
 boolean isAddSourcePage()
          Get the flag that indicates if the _sourcePage parameter should be appended to the URL.
 Boolean isPrependContext()
          Get the flag that indicates if the application context should be included in the URL.
 void setAddSourcePage(boolean addSourcePage)
          Set the flag that indicates if the _sourcePage parameter should be appended to the URL.
 void setAnchor(String anchor)
          Sets the anchor element that is appended at the end of the URL.
 void setBeanclass(Object beanclass)
          Sets the bean class (String FQN or Class) to generate a link for.
 void setEvent(String event)
          Sets the (optional) event name that the link will trigger.
 void setPrependContext(Boolean prependContext)
          Set the flag that indicates if the application context should be included in the URL.
 void setUrl(String url)
          Sets the URL that is supplied by the user/developer on the page.
 
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
doEndTag, doStartTag, getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkTagSupport

public LinkTagSupport()
Method Detail

getUrl

public String getUrl()
Gets the URL that is supplied by the user/developer on the page. This is the basis for constructing the eventual URL that the tag generates.

Returns:
the URL that was supplied by the user

setUrl

public void setUrl(String url)
Sets the URL that is supplied by the user/developer on the page. This is the basis for constructing the eventual URL that the tag generates.

Parameters:
url - the URL supplied on the page

addParameter

public void addParameter(String name,
                         Object valueOrValues)
Used by stripes:param tags (and possibly other tags at some distant point in the future) to add a parameter to the parent link tag.

Specified by:
addParameter in interface ParameterizableTag
Parameters:
name - the name of the parameter(s) to add
valueOrValues -

getParameters

public Map<String,Object> getParameters()
Retrieves the parameter values set on the tag.


clearParameters

public void clearParameters()
Clears all existing parameters. Subclasses should be careful to call this in doEndTag() to ensure that parameter state is cleared between pooled used of the tag.


setEvent

public void setEvent(String event)
Sets the (optional) event name that the link will trigger.


getEvent

public String getEvent()
Gets the (optional) event name that the link will trigger.


setBeanclass

public void setBeanclass(Object beanclass)
Sets the bean class (String FQN or Class) to generate a link for. Provides an alternative to using href for targeting ActionBeans.

Parameters:
beanclass - the name of an ActionBean class, or Class object

getBeanclass

public Object getBeanclass()
Gets the bean class (String FQN or Class) to generate a link for. Provides an alternative to using href for targeting ActionBeans.

Returns:
the name of an ActionBean class, or Class object

getAnchor

public String getAnchor()
Gets the anchor element that is appended at the end of the URL.

Returns:
the anchor element

setAnchor

public void setAnchor(String anchor)
Sets the anchor element that is appended at the end of the URL. If the provided URL (set using setUrl method) already contains the anchor, then the anchor specified by this attribute takes precedence.

Parameters:
anchor - the name of the anchor to set

isAddSourcePage

public boolean isAddSourcePage()
Get the flag that indicates if the _sourcePage parameter should be appended to the URL.

Returns:
true if _sourcePage is to be appended to the URL; false otherwise

setAddSourcePage

public void setAddSourcePage(boolean addSourcePage)
Set the flag that indicates if the _sourcePage parameter should be appended to the URL.


isPrependContext

public Boolean isPrependContext()
Get the flag that indicates if the application context should be included in the URL.


setPrependContext

public void setPrependContext(Boolean prependContext)
Set the flag that indicates if the application context should be included in the URL.


getPreferredBaseUrl

protected String getPreferredBaseUrl()
                              throws StripesJspException
Returns the base URL that should be used for building the link. This is derived from the 'beanclass' attribute if it is set, else from the 'url' attribute.

Returns:
the preferred base URL for the link
Throws:
StripesJspException - if a beanclass attribute was specified, but does not identify an existing ActionBean

buildUrl

protected String buildUrl()
                   throws StripesJspException
Builds the URL based on the information currently stored in the tag. Ensures that all parameters are appended into the URL, along with event name if necessary and the source page information.

Returns:
the fully constructed URL
Throws:
StripesJspException - if the base URL cannot be determined


? Copyright 2005-2006, Stripes Development Team.