org.apache.beehive.netui.tags.template
Class Attribute

Object
  extended by TagSupport
      extended by Attribute
All Implemented Interfaces:
Serializable, IterationTag, JspTag, Tag, TemplateConstants

public class Attribute
extends TagSupport
implements TemplateConstants

The Attribute tag defines an attribute within a template that may be set from a content page. For example, the page's title may be defined as an attribute in the template and then provided by each content page using the template. The attribute has a name and default value. If the content page specifies a value for the attribute it will be used, otherwise the default value is used.

See Also:
Serialized Form
Example

In this sample, a <netui-template:attribute> tag defines a value placeholder within a <td> tag

    <td colspan="3" bgcolor="<netui-template:attribute name="headerColor" defaultValue="#ffffff"/>">

Now a content JSP page can control the background color of the <td>.

    <netui-template:setAttribute name="headerColor" value="lightgreen"/>
The HTML rendered in the browser will appear as follows.
    <td colspan="3" bgcolor="lightgreen">

Field Summary
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface TemplateConstants
TEMPLATE_ATTRIBUTES, TEMPLATE_SECTIONS
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
Attribute()
           
 
Method Summary
 int doStartTag()
          Renders the content of the attribute.
protected  void localRelease()
          Resets all of the fields of the tag.
 void setDefaultValue(String defaultValue)
          Sets the defaultValue for the Attribute.
 void setName(String name)
          Sets the name for the Attribute.
 
Methods inherited from class TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute()
Method Detail

setName

public void setName(String name)
Sets the name for the Attribute. An attribute may be used more than once in a template page.

Parameters:
name - The name of the attribute. The name does not need to be unique because it may be used more than once on the page.

setDefaultValue

public void setDefaultValue(String defaultValue)
Sets the defaultValue for the Attribute. If the content page does not define a value for this attribute through the SetAttribute tag, then the defaultValue will be used. If neither a value nor defaultValue is set, then the empty String "" will be output.

Parameters:
defaultValue - The value to set the defaultValue property.

doStartTag

public int doStartTag()
               throws JspException
Renders the content of the attribute.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class TagSupport
Returns:
EVAL_PAGE to continue evaluation of the page.
Throws:
JspException - If there is any failure in the tag.

localRelease

protected void localRelease()
Resets all of the fields of the tag.