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 FormatString

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.FormatTag
                  extended by com.bea.wlw.netui.tags.html.FormatString
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class FormatString
extends FormatTag

A formatter used to format strings. FormatString uses the following pattern syntax:

The '#' character gets replaced by the next character in the string getting formatted, while other characters get put in as literals. For example:

String "5555555555" with pattern "(###)###-####" would result in: (555)555-5555.

The '*' character will display all characters in the string at that point in the pattern. For example:

String "123456" with pattern "#-*!" would result in: 1-23456!

If a result with a '#' or '*' character showing is desired, the '#' or '*' needs to be escaped with the '$' character. For example:

String "ABCD" with pattern "$#-####" would result in: #-ABCD.

To show a '$' in the result, the '$' character needs to be escaped. For example:

String "1234" with pattern "$$#,###" would result in: $1,234

If the truncate attribute is set to "true", characters in the string that exceed the pattern will be dropped. Otherwise, they will be appended to the end of the formatted string.

Attribute Descriptions
AttributeRequiredRuntime Expression EvaluationData Bindable
countryNoNoNo
The country code used to determine the locale
languageNoNoNo
The language code used to determine the locale
patternNoNoRead Only
The pattern used to format this string
truncateNoNoNo
A boolean specifying whether characters that exceed the pattern's length should be dropped.

See Also:
FormatDate, FormatNumber, Serialized Form
Example:
In this sample, the String "2125555555" will be formatted to this form: (212)555-5555.
    <netui:label value="2125555555">
        <netui:formatString pattern="phone (###) ###-####"/>
    </netui:label> 

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp
Beadoc.see:
<netui:format...> Tag Samples
Beadoc.tagdescription:
A formatter used to format strings.

The <netui:formatString> tag formats the output of its parent tag. For example:

     <netui:label value="{pageFlow.phone}">
         <netui:formatString pattern="phone number: (###) ###-####"/>
     </netui:label> 

<netui:formatString> uses the following pattern syntax:

The # character is a placeholder for individual characters in the String to be formatted, while other characters are treated as literals. For example:

String "5555555555" with pattern "(###)###-####" would result in: (555)555-5555.

The * character displays all remaining characters in the String. For example:

String "123456" with pattern "#-*!" would result in: 1-23456!

If a result with a '#' or '*' character showing is desired, the '#' or '*' needs to be escaped with the '$' character. For example:

String "ABCD" with pattern "$#-####" would result in: #-ABCD.

To show a '$' in the result, the '$' character needs to be escaped. For example:

String "1234" with pattern "$$#,###" would result in: $1,234

If the truncate attribute is set to "true", characters in the String that exceed the pattern will be dropped. Otherwise, they will be appended to the end of the formatted String.


Nested Class Summary
static class FormatString.StringFormatter
          Internal FormatTag.Formatter which performs its own string parsing and formatting.
 
Nested classes/interfaces inherited from class com.bea.wlw.netui.tags.html.FormatTag
FormatTag.Formatter
 
Field Summary
protected  boolean truncate
          Whether or not pattern-exceeding characters should be dropped.
 
Fields inherited from class com.bea.wlw.netui.tags.html.FormatTag
pattern, patternValue
 
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
id, 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
FormatString()
           
 
Method Summary
 int doStartTag()
          Create the internal Formatter instance and perform the formatting.
 String getTagName()
          Return the name of the Tag.
 boolean getTruncate()
          Gets whether or not pattern-exceeding characters should be dropped.
protected  void localRelease()
          Release any acquired resources.
 void setTruncate(boolean truncate)
          Sets whether or not pattern-exceeding characters should be dropped.
 
Methods inherited from class com.bea.wlw.netui.tags.html.FormatTag
getCountry, getLanguage, getLocale, getPattern, setCountry, setLanguage, setPattern
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, 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, doEndTag, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, 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

truncate

protected boolean truncate
Whether or not pattern-exceeding characters should be dropped.

Constructor Detail

FormatString

public FormatString()
Method Detail

getTruncate

public boolean getTruncate()
Gets whether or not pattern-exceeding characters should be dropped.

Returns:
the truncate value ("true" or "false").

setTruncate

public void setTruncate(boolean truncate)
Sets whether or not pattern-exceeding characters should be dropped.

Parameters:
truncate - - "true" or "false"
Beadoc.attributedescription:
A boolean specifying whether characters that exceed the pattern's length should be dropped.
Beadoc.attributesyntaxvalue:
boolean_truncate
Beadoc.databindable:
false

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Create the internal Formatter instance and perform the formatting.

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

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class FormatTag

getTagName

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

Specified by:
getTagName in class AbstractBaseTag

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