net.sourceforge.stripes.tag
Class HtmlTagSupport

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
All Implemented Interfaces:
DynamicAttributes, JspTag, Tag
Direct Known Subclasses:
ErrorsFooterTag, ErrorsHeaderTag, ErrorsTag, FieldMetadataTag, FormTag, IndividualErrorTag, InputOptionsCollectionTag, InputTagSupport, LinkTagSupport, MessagesTag

public abstract class HtmlTagSupport
extends StripesTagSupport
implements DynamicAttributes

Provides basic facilities for any tag that wishes to mimic a standard HTML/XHTML tag. Includes getters and setters for all basic HTML attributes and JavaScript event attributes. Also includes several of the support methods from the Tag interface, but does not directly or indirectly implement either Tag or BodyTag.

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
HtmlTagSupport()
           
 
Method Summary
protected
<R> R
evaluateExpression(String expression, Class<R> resultType)
          Evaluates a single expression and returns the result.
protected  String get(String name)
          Gets the value of the named attribute, or null if it is not set.
 String getAccesskey()
           
protected  Map<String,String> getAttributes()
          Gets the map containing the attributes of the tag.
 BodyContent getBodyContent()
          Returns the BodyContent of the tag if one has been provided by the JSP container.
protected  String getBodyContentAsString()
          Checks to see if there is a body content for this tag, and if its value is non-null and non-zero-length.
 String getCssClass()
           
 String getDir()
           
 String getId()
           
 String getLang()
           
 String getOnblur()
           
 String getOnchange()
           
 String getOnclick()
           
 String getOndblclick()
           
 String getOnfocus()
           
 String getOnkeydown()
           
 String getOnkeypress()
           
 String getOnkeyup()
           
 String getOnmousedown()
           
 String getOnmousemove()
           
 String getOnmouseout()
           
 String getOnmouseover()
           
 String getOnmouseup()
           
 String getOnselect()
           
 String getStyle()
           
 String getTabindex()
           
 String getTitle()
           
 void release()
          Release method to clean up the state of the tag ready for re-use.
protected  void set(String name, String value)
          Sets the named attribute to the supplied value.
 void setAccesskey(String accesskey)
           
 void setBodyContent(BodyContent bodyContent)
          Called by the JSP container to set the BodyContent on the tag.
 void setClass(String cssClass)
           
 void setCssClass(String cssClass)
           
 void setDir(String dir)
           
 void setDynamicAttribute(String uri, String name, Object value)
          Accepts any dynamic attributes that are supplied to the tag and stored them in the map of attributes that get written back to the page.
 void setId(String id)
           
 void setLang(String lang)
           
 void setOnblur(String onblur)
           
 void setOnchange(String onchange)
           
 void setOnclick(String onclick)
           
 void setOndblclick(String ondblclick)
           
 void setOnfocus(String onfocus)
           
 void setOnkeydown(String onkeydown)
           
 void setOnkeypress(String onkeypress)
           
 void setOnkeyup(String onkeyup)
           
 void setOnmousedown(String onmousedown)
           
 void setOnmousemove(String onmousemove)
           
 void setOnmouseout(String onmouseout)
           
 void setOnmouseover(String onmouseover)
           
 void setOnmouseup(String onmouseup)
           
 void setOnselect(String onselect)
           
 void setStyle(String style)
           
 void setTabindex(String tabindex)
           
 void setTitle(String title)
           
 String toString()
          Returns a String representation of the class, including the map of attributes that are set on the tag, the toString of its parent tag, and the pageContext.
protected  void writeAttributes(JspWriter writer)
          For every attribute stored in the attributes map for this tag, writes out the tag attributes in the form x="y".
protected  void writeCloseTag(JspWriter writer, String tag)
          Writes out a close tag using the tag name supplied.
protected  void writeOpenTag(JspWriter writer, String tag)
          Writes out an opening tag.
protected  void writeSingletonTag(JspWriter writer, String tag)
          Writes out a singleton tag (aka a bodiless tag or self-closing tag).
 
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

HtmlTagSupport

public HtmlTagSupport()
Method Detail

set

protected final void set(String name,
                         String value)
Sets the named attribute to the supplied value.


get

protected final String get(String name)
Gets the value of the named attribute, or null if it is not set.


getAttributes

protected final Map<String,String> getAttributes()
Gets the map containing the attributes of the tag.


setDynamicAttribute

public void setDynamicAttribute(String uri,
                                String name,
                                Object value)
                         throws JspException
Accepts any dynamic attributes that are supplied to the tag and stored them in the map of attributes that get written back to the page.

Specified by:
setDynamicAttribute in interface DynamicAttributes
Parameters:
uri - the URI of the namespace of the attribute if it has one. Totally ignored!
name - the name of the attribute
value - the value of the attribute
Throws:
JspException - not thrown from this class; included so that subclasses can override the method and throw the interface exception

getBodyContent

public BodyContent getBodyContent()
Returns the BodyContent of the tag if one has been provided by the JSP container.


setBodyContent

public void setBodyContent(BodyContent bodyContent)
Called by the JSP container to set the BodyContent on the tag.


release

public void release()
Release method to clean up the state of the tag ready for re-use.

Specified by:
release in interface Tag
Overrides:
release in class StripesTagSupport

getBodyContentAsString

protected String getBodyContentAsString()
Checks to see if there is a body content for this tag, and if its value is non-null and non-zero-length. If so, returns it as a String, otherwise returns null.

Returns:
String the value of the body if one was set

writeOpenTag

protected void writeOpenTag(JspWriter writer,
                            String tag)
                     throws JspException
Writes out an opening tag. Uses the parameter "tag" to determine the name of the open tag and then uses the map of attributes assembled through various setter calls to fill in the tag attributes.

Parameters:
writer - the JspWriter to write the open tag to
tag - the name of the tag to use
Throws:
JspException - if the JspWriter causes an exception

writeCloseTag

protected void writeCloseTag(JspWriter writer,
                             String tag)
                      throws JspException
Writes out a close tag using the tag name supplied.

Parameters:
writer - the JspWriter to write the open tag to
tag - the name of the tag to use
Throws:
JspException - if the JspWriter causes an exception

writeSingletonTag

protected void writeSingletonTag(JspWriter writer,
                                 String tag)
                          throws JspException
Writes out a singleton tag (aka a bodiless tag or self-closing tag). Similar to writeOpenTag except that instead of leaving the tag open, it closes the tag.

Parameters:
writer - the JspWriter to write the open tag to
tag - the name of the tag to use
Throws:
JspException - if the JspWriter causes an exception

writeAttributes

protected void writeAttributes(JspWriter writer)
                        throws IOException
For every attribute stored in the attributes map for this tag, writes out the tag attributes in the form x="y". All attributes are HTML encoded before being written to the page to ensure that HTML special characters are rendered properly.

Parameters:
writer - the JspWriter to write the open tag to
Throws:
IOException - if the JspWriter causes an exception

evaluateExpression

protected <R> R evaluateExpression(String expression,
                                   Class<R> resultType)
                        throws StripesJspException
Evaluates a single expression and returns the result. If the expression cannot be evaluated then an ELException is caught, wrapped in a JspException and re-thrown.

Parameters:
expression - the expression to be evaluated
resultType - the Class representing the desired return type from the expression
Throws:
StripesJspException - when an ELException occurs trying to evaluate the expression

toString

public String toString()
Returns a String representation of the class, including the map of attributes that are set on the tag, the toString of its parent tag, and the pageContext.

Overrides:
toString in class Object

setId

public void setId(String id)

getId

public String getId()

setClass

public void setClass(String cssClass)

setCssClass

public void setCssClass(String cssClass)

getCssClass

public String getCssClass()

setTitle

public void setTitle(String title)

getTitle

public String getTitle()

setStyle

public void setStyle(String style)

getStyle

public String getStyle()

setDir

public void setDir(String dir)

getDir

public String getDir()

setLang

public void setLang(String lang)

getLang

public String getLang()

setTabindex

public void setTabindex(String tabindex)

getTabindex

public String getTabindex()

setAccesskey

public void setAccesskey(String accesskey)

getAccesskey

public String getAccesskey()

setOnfocus

public void setOnfocus(String onfocus)

getOnfocus

public String getOnfocus()

setOnblur

public void setOnblur(String onblur)

getOnblur

public String getOnblur()

setOnselect

public void setOnselect(String onselect)

getOnselect

public String getOnselect()

setOnchange

public void setOnchange(String onchange)

getOnchange

public String getOnchange()

setOnclick

public void setOnclick(String onclick)

getOnclick

public String getOnclick()

setOndblclick

public void setOndblclick(String ondblclick)

getOndblclick

public String getOndblclick()

setOnmousedown

public void setOnmousedown(String onmousedown)

getOnmousedown

public String getOnmousedown()

setOnmouseup

public void setOnmouseup(String onmouseup)

getOnmouseup

public String getOnmouseup()

setOnmouseover

public void setOnmouseover(String onmouseover)

getOnmouseover

public String getOnmouseover()

setOnmousemove

public void setOnmousemove(String onmousemove)

getOnmousemove

public String getOnmousemove()

setOnmouseout

public void setOnmouseout(String onmouseout)

getOnmouseout

public String getOnmouseout()

setOnkeypress

public void setOnkeypress(String onkeypress)

getOnkeypress

public String getOnkeypress()

setOnkeydown

public void setOnkeydown(String onkeydown)

getOnkeydown

public String getOnkeydown()

setOnkeyup

public void setOnkeyup(String onkeyup)

getOnkeyup

public String getOnkeyup()


? Copyright 2005-2006, Stripes Development Team.