BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.html
Class Label

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.html.Label
All Implemented Interfaces:
Formattable, HtmlConstants, IAttributeConsumer, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class Label
extends AbstractBaseTag
implements Formattable, IAttributeConsumer

Generates styled text span based on an expression or literal value.

Attribute Descriptions
AttributeRequiredRuntime Expression Evaluation Data Bindable
dataformatasNoNoNo
The data format of the Label
defaultValueNoNoRead Only
A literal default value that will be used when an expression results in a NULL value. If the default value is an expression, the any defined formatters will be applied to the default value. If the defaultValue is not an expression, the value will be output without applying formatters. If the default value is being output and contains a XML Entity, such as " ", then the default value is output without applying any escaping to it. The result default value acts like a literal string.
escapeWhiteSpaceForHtmlNoNoNo
Flag that will set an escape for white space. The default value is false.
idNoNoNo
The id attribute has been deprecated; instead, use tagId. The id of the span surrounding the Label text. You should use tagId which will encode the id correctly for containers such as the Portal which rewrite IDs to make them unique.
tagIdNoNoNo
The id of this label. The real id written to the HTML stream may be changed by the container (Portal), but may be looked up with the tagId value through the JavaScript method getNetuiTagName( tagId, tag ) method written by the <netui:html> tag.
valueYesNoRead Only
A literal value or an expression that resolves to a bean property.

If the resulting value to be output is the " " String, it will output as the value "&nbsp;".

See Also:
Content, Serialized Form
Example:
In this first sample, a <netui:label> tag displays the Form Bean's firstName property. The <netui:label> tag will resolve this data binding expression, and display its value.
    <netui:label value="{actionForm.firstName}" />

In this next sample, the value attribute will resolve to null. This causes the defaultValue to be displayed. The user will see ' '.

    <netui:label value="{pageFlow.somethingNull}" defaultValue="&nbsp;"/>

In this next sample, the HTML will contain the text "&amp;nbsp;" and the user will see '&nbsp;'

    <netui:label value="{pageFlow.somethingNull}" defaultValue="&amp;nbsp;"/>

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/label/
Beadoc.see:
<netui:label> Tag Sample
Beadoc.tagdescription:

Generates styled text based on a String literal or data binding expression.

The <netui:label> tag is similar to the Content tag, except with respect to the way that it treats characters sensitive to HTML browsers. The <netui:label> tag filters the input string for browser-sensitive characters and replaces these characters with the corresponding entity strings. For example, if you pass the string '&amp;' to a <netui:label> tag, the string '&amp;amp;' will be written to the HTML source file, and the following will be displayed in the browser: '&amp;'.

The following table shows how the <netui:label> and <netui:content> tags treat HTML-sensitive characters.

tag generated HTML source displayed in browser
<netui:content value="&amp;"/> &amp; &
<netui:label value="&amp;"/> &amp;amp; &amp;

Note: escaping is not applied to browser-sensitive characters in the defaultValue attribute.


Field Summary
protected  String dataformatas
          The data format of the Label.
protected  ArrayList formatters
           
protected  Object labelObject
           
protected  String value
          The text of the Label.
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
Label()
           
 
Method Summary
 void addFormatter(FormatTag.Formatter formatter)
          Adds a FormatTag.Formatter to the Label's set of formatters
 int doEndTag()
          Render the label.
 int doStartTag()
          Prepare the label formatters.
protected  String filter(String value, boolean markupHTMLSpaceReturn)
          Filter the specified string for characters that are senstive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.
protected  String formatText(Object text)
           
 String getDataformatas()
          Gets the data formatters of the Label.
 String getDefaultValue()
          Return the default value of this Label.
 String getId()
          Return the ID of the label.
 String getOnClick()
          Gets the onClick javascript event.
 String getOnDblClick()
          Gets the onDblClick javascript event.
 String getOnKeyDown()
          Gets the onKeyDown javascript event.
 String getOnKeyPress()
          Gets the onKeyPress javascript event.
 String getOnKeyUp()
          Gets the onKeyUp javascript event.
 String getOnMouseDown()
          Gets the onMouseDown javascript event.
 String getOnMouseMove()
          Gets the onMouseMove javascript event.
 String getOnMouseOut()
          Gets the onMouseOut javascript event.
 String getOnMouseOver()
          Gets the onMouseOver javascript event.
 String getOnMouseUp()
          Gets the onMouseUp javascript event.
protected  AbstractHtmlState getState()
          This method will return the state associated with the tag.
 String getStyle()
          Gets the style of the rendered html tag.
 String getStyleClass()
          Gets the style class of the rendered html tag.
 String getTabindex()
          Gets the tabIndex of the rendered html tag.
 String getTagId()
          Return the ID of the <span> that contains the label text.
 String getTagName()
          Return the name of the Tag.
 String getValue()
          Gets the text of the Label.
 boolean isEscapeWhiteSpaceForHtml()
          Gets the boolean value indicating if we are escaping the whitespace characters in HTML.
protected  void localRelease()
          Release any acquired resources.
 void setAttribute(String name, String value)
          Set an attribute value.
 void setDataformatas(String dataformatas)
          Sets the data format of the Label.
 void setDefaultValue(String defaultValue)
          Set the default value of this Label.
 void setEscapeWhiteSpaceForHtml(boolean escapeWhiteSpace)
          Sets a boolean flag indicating if we will escape white space for HTML.
 void setId(String id)
          Set the ID of the label.
 void setOnClick(String onclick)
          Sets the onClick javascript event.
 void setOnDblClick(String ondblclick)
          Sets the onDblClick javascript event.
 void setOnKeyDown(String onkeydown)
          Sets the onKeyDown javascript event.
 void setOnKeyPress(String onkeypress)
          Sets the onKeyPress javascript event.
 void setOnKeyUp(String onkeyup)
          Sets the onKeyUp javascript event.
 void setOnMouseDown(String onmousedown)
          Sets the onMouseDown javascript event.
 void setOnMouseMove(String onmousemove)
          Sets the onMouseMove javascript event.
 void setOnMouseOut(String onmouseout)
          Sets the onMouseOut javascript event.
 void setOnMouseOver(String onmouseover)
          Sets the onMouseOver javascript event.
 void setOnMouseUp(String onmouseup)
          Sets the onMouseUp javascript event.
 void setStyle(String style)
          Sets the style of the rendered html tag.
 void setStyleClass(String styleClass)
          Sets the style class of the rendered html tag.
 void setTabindex(String tabindex)
          Sets the tabIndex of the rendered html tag.
 void setTagId(String tagId)
          Set the ID of the label.
 void setValue(String value)
          Sets the text of the Label.
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

Field Detail

formatters

protected ArrayList formatters
Exclude:

dataformatas

protected String dataformatas
The data format of the Label.


labelObject

protected Object labelObject
Exclude:

value

protected String value
The text of the Label.

Constructor Detail

Label

public Label()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in class AbstractBaseTag

getState

protected AbstractHtmlState getState()
This method will return the state associated with the tag. This is used by this base class to access the individual state objects created by the tags.

Returns:
a subclass of the AbstractHtmlState class.

setAttribute

public void setAttribute(String name,
                         String value)
                  throws javax.servlet.jsp.JspException
Set an attribute value. The name represents the name of the attribute. The value represents the value and may contain a netui expression. This method may result in errors being generated. This requires that the tag buffer its body and write attributes in the end tag. For the label tag it is not legal to set the id or name attributes with this method.

Specified by:
setAttribute in interface IAttributeConsumer
Parameters:
name - The name of the attribute. This value may not be null or the empty string.
value - The value of the attribute. This may contain a netui expression.
Throws:
javax.servlet.jsp.JspException - A JspException may be thrown if there is an error setting the attribute.

setDataformatas

public void setDataformatas(String dataformatas)
Sets the data format of the Label.

Parameters:
dataformatas - - the data format.
Beadoc.attributedescription:
The data format of the output.
Beadoc.attributesyntaxvalue:
string_dataFormatAs
Beadoc.databindable:
false

getDataformatas

public String getDataformatas()
Gets the data formatters of the Label.

Returns:
the data format.

getDefaultValue

public String getDefaultValue()
Return the default value of this Label.

Returns:
the Label's default value

setDefaultValue

public void setDefaultValue(String defaultValue)
Set the default value of this Label. This can be an expression. If the default value is an expression all formatters will be applied, otherwise the default value will be output without being formatted.

Parameters:
defaultValue - - the default value
Beadoc.attributedescription:
A literal or data binding expression default value that will be used in the event that the value attribute resolves to NULL. If the defaultValue is an expression, then any format tags (<netui:formatString>, etc.) will be applied to the value. If the defaultValue is not an expression, format tags will not be applied. If the defaultValue contains an entity string, such as "&nbsp;", then the default value is output without applying any escaping to it.
Beadoc.attributesyntaxvalue:
string_defaultValue
Beadoc.databindable:
Read Only

getId

public String getId()
Return the ID of the label.

Overrides:
getId in class javax.servlet.jsp.tagext.TagSupport
Returns:
the ID.

setId

public void setId(String id)
Set the ID of the label.

Overrides:
setId in class javax.servlet.jsp.tagext.TagSupport
Parameters:
id - - the ID.
Beadoc.attributedescription:
The id attribute is deprecated, use the tagId attribute instead. The id attribute of the rendered HTML tag. You should use the tagId attribute which will encode the id correctly for containers such as the Portal which needs to rewrite id's to make them unique.
Beadoc.attributesyntaxvalue:
string_id
Beadoc.databindable:
false

getTagId

public String getTagId()
Return the ID of the <span> that contains the label text. The id may be rewritten by the container (such as a portal) to make sure it is unique. JavaScript my lookup the actual id of the element by looking it up in the netui_names table written into the HTML.

Returns:
the ID.

setTagId

public void setTagId(String tagId)
Set the ID of the label.

Parameters:
tagId - - the ID.
Beadoc.attributedescription:

String value. Sets the id (or name) attribute of the rendered HTML tag. Note that the real id attribute rendered in the browser may be changed by the application container (for example, Portal containers may change the rendered id value to ensure the uniqueness of id's on the page). In this case, the real id rendered in the browser may be looked up through the JavaScript function getNetuiTagName( tagId, tag ).

For example, assume that some tag's tagId attribute is set to foo.

    <netui:textBox tagId="foo" />

Then the following JavaScript function will return the real id attribute rendered in the browser:

    getNetuiTagName( "foo", this )

To get a <netui:form> element and all of its children elements in JavaScript, use the same JavaScript function getNetuiTagName( tagId, tag ). For example, assume that there is a <netui:form> whose tagId attribute is set to bar.

    <netui:form tagId="bar" >

Then the following JavaScript function will return the <netui:form> element and its children (packaged as an array).

    document[getNetuiTagName( "bar", this )]

To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following JavaScript expression.

    document[getNetuiTagName("bar", this)][getNetuiTagName("foo", this)].value

The second parameter ensures that the JavaScript function begins its search within the correct Portlet scope. Pass the JavaScript keyword this as the second parameter. For detailed information on using the function getNetuiTagName( tagId, tag ) see Using JavaScript in Page Flow and Portal Applications.

Beadoc.attributesyntaxvalue:
string_tagId
Beadoc.databindable:
false

setValue

public void setValue(String value)
Sets the text of the Label.

Parameters:
value - - the Label value or expression.
Beadoc.attributedescription:
A literal or data binding expression.
Beadoc.attributesyntaxvalue:
string_or_expression_value
Beadoc.databindable:
Read Only

getValue

public String getValue()
Gets the text of the Label.

Returns:
the text value

setEscapeWhiteSpaceForHtml

public void setEscapeWhiteSpaceForHtml(boolean escapeWhiteSpace)
Sets a boolean flag indicating if we will escape white space for HTML. If this is true the white space charcters ' ' will be converted into " " and '\n' converted into "
". The result is that in HTML white space will be represented correctly. If this is false then white space will be output as it is found in the value.

Parameters:
escapeWhiteSpace - - boolean indicating if we are escaping for white space.
Beadoc.attributedescription:
Boolean. If set to true, white space will be escaped before it is output to the page. Default value is false.
Beadoc.attributesyntaxvalue:
boolean_escapeWhiteSpace
Beadoc.databindable:
false

isEscapeWhiteSpaceForHtml

public boolean isEscapeWhiteSpaceForHtml()
Gets the boolean value indicating if we are escaping the whitespace characters in HTML.

Returns:
the state of white space handling

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Prepare the label formatters.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Render the label.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class AbstractBaseTag

addFormatter

public void addFormatter(FormatTag.Formatter formatter)
Adds a FormatTag.Formatter to the Label's set of formatters

Specified by:
addFormatter in interface Formattable
Parameters:
formatter - - a FormatTag.Formatter added by a child FormatTag.

formatText

protected String formatText(Object text)
Exclude:

filter

protected String filter(String value,
                        boolean markupHTMLSpaceReturn)
Filter the specified string for characters that are senstive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.

Overrides:
filter in class AbstractBaseTag
Parameters:
value - The string to be filtered and returned
markupHTMLSpaceReturn - convert space characters and return characters to &nbsp; and <br /> marketup for html.
Exclude:

setTabindex

public void setTabindex(String tabindex)
Sets the tabIndex of the rendered html tag.

Parameters:
tabindex - - the tab index.
Beadoc.attributedescription:
The tabIndex of the rendered HTML tag. This attribute determines the position of the rendered HTML tag in the sequence of tags that the user may advance through by pressing the TAB key.
Beadoc.attributesyntaxvalue:
string_tabIndex
Beadoc.databindable:
false

getTabindex

public String getTabindex()
Gets the tabIndex of the rendered html tag.

Returns:
the tabindex.

setStyle

public void setStyle(String style)
Sets the style of the rendered html tag.

Parameters:
style - - the html style.
Beadoc.attributedescription:
Sets the style of the rendered HTML tag.
Beadoc.attributesyntaxvalue:
string_Style
Beadoc.databindable:
false

getStyle

public String getStyle()
Gets the style of the rendered html tag.

Returns:
the style.

setStyleClass

public void setStyleClass(String styleClass)
Sets the style class of the rendered html tag.

Parameters:
styleClass - - the html style class.
Beadoc.attributedescription:
The class of the rendered HTML tag.
Beadoc.attributesyntaxvalue:
string_Class
Beadoc.databindable:
false

getStyleClass

public String getStyleClass()
Gets the style class of the rendered html tag.

Returns:
the style class.

getOnClick

public String getOnClick()
Gets the onClick javascript event.

Returns:
the onClick event.

setOnClick

public void setOnClick(String onclick)
Sets the onClick javascript event.

Parameters:
onclick - - the onClick event.
Beadoc.attributedescription:
The onClick JavaScript event.
Beadoc.attributesyntaxvalue:
string_onClick
Beadoc.databindable:
false

getOnDblClick

public String getOnDblClick()
Gets the onDblClick javascript event.

Returns:
the onDblClick event.

setOnDblClick

public void setOnDblClick(String ondblclick)
Sets the onDblClick javascript event.

Parameters:
ondblclick - - the onDblClick event.
Beadoc.attributedescription:
The onDblClick JavaScript event.
Beadoc.attributesyntaxvalue:
string_onDblClick
Beadoc.databindable:
false

getOnKeyDown

public String getOnKeyDown()
Gets the onKeyDown javascript event.

Returns:
the onKeyDown event.

setOnKeyDown

public void setOnKeyDown(String onkeydown)
Sets the onKeyDown javascript event.

Parameters:
onkeydown - - the onKeyDown event.
Beadoc.attributedescription:
The onKeyDown JavaScript event.
Beadoc.attributesyntaxvalue:
string_onKeyDown
Beadoc.databindable:
false

getOnKeyPress

public String getOnKeyPress()
Gets the onKeyPress javascript event.

Returns:
the onKeyPress event.

setOnKeyPress

public void setOnKeyPress(String onkeypress)
Sets the onKeyPress javascript event.

Parameters:
onkeypress - - the onKeyPress event.
Beadoc.attributedescription:
The onKeyPress JavaScript event.
Beadoc.attributesyntaxvalue:
string_onKeyPress
Beadoc.databindable:
false

getOnKeyUp

public String getOnKeyUp()
Gets the onKeyUp javascript event.

Returns:
the onKeyUp event.

setOnKeyUp

public void setOnKeyUp(String onkeyup)
Sets the onKeyUp javascript event.

Parameters:
onkeyup - - the onKeyUp event.
Beadoc.attributedescription:
The onKeyUp JavaScript event.
Beadoc.attributesyntaxvalue:
string_onKeyUp
Beadoc.databindable:
false

getOnMouseDown

public String getOnMouseDown()
Gets the onMouseDown javascript event.

Returns:
the onMouseDown event.

setOnMouseDown

public void setOnMouseDown(String onmousedown)
Sets the onMouseDown javascript event.

Parameters:
onmousedown - - the onMouseDown event.
Beadoc.attributedescription:
The onMouseDown JavaScript event.
Beadoc.attributesyntaxvalue:
string_onMouseDown
Beadoc.databindable:
false

getOnMouseMove

public String getOnMouseMove()
Gets the onMouseMove javascript event.

Returns:
the onMouseMove event.

setOnMouseMove

public void setOnMouseMove(String onmousemove)
Sets the onMouseMove javascript event.

Parameters:
onmousemove - - the onMouseMove event.
Beadoc.attributedescription:
The onMouseMove JavaScript event.
Beadoc.attributesyntaxvalue:
string_onMouseMove
Beadoc.databindable:
false

getOnMouseOut

public String getOnMouseOut()
Gets the onMouseOut javascript event.

Returns:
the onMouseOut event.

setOnMouseOut

public void setOnMouseOut(String onmouseout)
Sets the onMouseOut javascript event.

Parameters:
onmouseout - - the onMouseOut event.
Beadoc.attributedescription:
The onMouseOut JavaScript event.
Beadoc.attributesyntaxvalue:
string_onMouseOut
Beadoc.databindable:
false

getOnMouseOver

public String getOnMouseOver()
Gets the onMouseOver javascript event.

Returns:
the onMouseOver event.

setOnMouseOver

public void setOnMouseOver(String onmouseover)
Sets the onMouseOver javascript event.

Parameters:
onmouseover - - the onMouseOver event.
Beadoc.attributedescription:
The onMouseOver JavaScript event.
Beadoc.attributesyntaxvalue:
string_onMouseOver
Beadoc.databindable:
false

getOnMouseUp

public String getOnMouseUp()
Gets the onMouseUp javascript event.

Returns:
the onMouseUp event.

setOnMouseUp

public void setOnMouseUp(String onmouseup)
Sets the onMouseUp javascript event.

Parameters:
onmouseup - - the onMouseUp event.
Beadoc.attributedescription:
The onMouseUp JavaScript event.
Beadoc.attributesyntaxvalue:
string_onMouseUp
Beadoc.databindable:
false

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.