|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.jsp.tagext.TagSupport
jp.terasoluna.fw.web.taglib.StringFormatterTagBase
public abstract class StringFormatterTagBase
Abstract class for custom tag that formats and outputs the string or defines it as scripting variable.
The class of custom tag that formats the trimming of the string,is created by inheriting this class.
(fmtx
custom tag library which is provided by TERASOLUNA
)
Depending on the id
attribute, the string which is formatted by this class is either output to the response
or set to scripting variable.
The priority sequence for the string to be formatted is as follows.
value
attribute is specified,
the string specified in that attribute is formatted.
bean
name is specified in the name
attribute,
property which is specified in property
attribute of bean
instance, is formatted.
When name
attribute is specified and property
attribute is
not specified, value of the instance (string of object which is returned by toString()
method)
which is specified in name
attribute needs to be formatted.
When the bean
specified in name
attribute
is not found, the custom tag operation is decided depending on the
ignore
attribute.
When ignore
attribute is true and bean
is not
found, it is ignored and nothing is output.
(When id
attribute is specified, it is not set to scripting variable).
When ignore
attribute is false(default) and the bean
specified by name
attribute, is not found,
JspException
is thrown.
scope
attribute can be specified as the search target of
bean
.
When scope
attribute is not specified, search is performed
as per the search order of findAttribute()
method in javax.servlet.jsp.PageContext
class.
When id
attribute is specified,the formatted string is not output but is
set to the scripting variable with the name specified in id
attribute.
When filter
attribute is true
(default),
special HTML
characters (It is processed by using the filter()
method of
org.apache.struts.util.ResponceUtils
class.The special HTML characters are namely, "<", ">", "&" and """)
are escaped when they are output.
At the time of setting the string to scripting variable, filter
attribute is ignored and
formatted string is set to scripting variable as it is.
When replaceSpToNbsp
attribute is true
(default),
it is converted to " " when 1Byte code space (half-width space) exists.
At the time of setting the string to scripting variable, replaceSpToNbsp
attribute is ignored
and formatted string is set to scripting variable as it is.
In the subclass that inherits StringFormatterTagBase
class,
abstract method doFormat()
that formats the actual string, is implemented.
In StringFormatterTagBase
, folowing attributes are supported.
Attribute name | Default | Required | Execution time | Description |
id | - | Any | false |
It is specified when the formatted string is to be set to scripting variable without
outputting the string.When the formatted string is to be set to scripting variable,
irrespective of whether the filter is specified or not, the special
HTML characters are not escaped.
|
filter | true | - | Any |
At the time of outputting the formatted string, specify whether the special
HTML characetrs are to be escaped.
It is ignored when id attribute is specified.
|
ignore | false | - | Any |
When the bean which is specified in name attribute,specify whether
to ignore. If false is specified and bean is not found,
JspException is thrown.
|
name | - | - | Any |
bean name that contains the string to be formatted in the property.
When property attribute is not specified, the string which is returned by
string representation toString() method of the instance needs to be formatted.
This instance is specified in string representation name attribute.
When value attribute is specified, it is ignored.
|
property | - | - | Any | Property name which is accessed in bean .
This bean is specified in the name attribute.
When value attribute is specified, it is ignored.
|
scope | (Search order of findAttribute() method) |
- | Any | Scope to search the bean which is specified
in name attribute.
|
value | None | - | Any | String to be formatted. When value attribute is specified,
name attribute and property attribute are ignored.
|
replaceSpToNbsp |
- | false |
true |
This attribute is set to true.
When the value of specified bean property contains 1Byte code space,
it is replaced with .
To invalidate, it is necessary to explicitly set false in this attribute.
When id attribute is specified, it is ignored.
|
In StringFormatterTagBase
, following variables are supported.
Scripting variable name | Type | Available range of variable | Description |
Name specified in id attribute of custom tag. |
java.lang.String |
After start tag | Variable name in case when string is output to a scripting variable and not output in this custom tag. |
LeftTag
,
RTrimTag
,
LTrimTag
,
TrimTag
,
Serialized FormField Summary | |
---|---|
protected boolean |
filter
Check whether to filter the special HTML characters. Default is true. |
protected java.lang.String |
id
Name of scriptign variable which is used on the respective page. |
protected boolean |
ignore
It is ignored when bean is not found.(nothing is output) Throws exception when it is not ignored. Default is false(throws exception). |
private static org.apache.commons.logging.Log |
log
Log class |
protected java.lang.String |
name
Bean name that includes the data to be formatted. |
protected java.lang.String |
property
Property name which is accessed in specified bean. |
protected boolean |
replaceSpToNbsp
Half-width space is replaced with . |
protected java.lang.String |
scope
Scope to search the specified bean. |
protected java.lang.String |
value
Value (string) to be formatted |
Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
pageContext |
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 | |
---|---|
StringFormatterTagBase()
|
Method Summary | |
---|---|
protected abstract java.lang.String |
doFormat(java.lang.String s)
Abstract method that formats the string. It is overridden in subclass. |
int |
doStartTag()
Method which is called at the time of starting the tag evaluation. |
boolean |
getFilter()
Get filter method to decide whether the special HTML characters are to be filtered. |
java.lang.String |
getId()
Fetches the name of scripting variable. |
boolean |
getIgnore()
GetIgnore method to decide whether to ignore when bean is not found. |
java.lang.String |
getName()
Fetches the bean name that includes the data to be formatted. |
java.lang.String |
getProperty()
Fetches the property name which acccessed in the specified bean. |
boolean |
getReplaceSpToNbsp()
get method of replaceSpToNbsp |
java.lang.String |
getScope()
Fetches the scope to search the specified bean. |
java.lang.String |
getValue()
Fetches the value to be formatted. |
void |
release()
Releases all allocated resources. |
void |
setFilter(boolean filter)
setFilter method to filter the special HTML characters. |
void |
setId(java.lang.String id)
Sets name of scripting variable. |
void |
setIgnore(boolean ignore)
setIgnore method to decide whether to ignore when bean is not found. |
void |
setName(java.lang.String name)
Sets the bean name that includes the data to be formatted. |
void |
setProperty(java.lang.String property)
Sets the property name which is accessed in specified bean. |
void |
setReplaceSpToNbsp(boolean replaceSpToNbsp)
set method of replaceSpToNbsp |
void |
setScope(java.lang.String scope)
Sets the scope to search the specified bean. |
void |
setValue(java.lang.String value)
Sets the value to be formatted. |
Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
doAfterBody, doEndTag, findAncestorWithClass, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static org.apache.commons.logging.Log log
protected java.lang.String id
protected boolean filter
protected boolean ignore
protected java.lang.String name
protected java.lang.String property
protected java.lang.String scope
protected java.lang.String value
protected boolean replaceSpToNbsp
Replace half-width space with
.
Constructor Detail |
---|
public StringFormatterTagBase()
Method Detail |
---|
public java.lang.String getId()
getId
in class javax.servlet.jsp.tagext.TagSupport
public void setId(java.lang.String id)
setId
in class javax.servlet.jsp.tagext.TagSupport
id
- Scripting variable namepublic boolean getFilter()
public void setFilter(boolean filter)
filter
- It is true when special HTML characters are to be filteredpublic boolean getIgnore()
public void setIgnore(boolean ignore)
ignore
- It is true when it is ignoredpublic java.lang.String getName()
public void setName(java.lang.String name)
name
- bean namepublic java.lang.String getProperty()
public void setProperty(java.lang.String property)
property
- Property namepublic java.lang.String getScope()
public void setScope(java.lang.String scope)
scope
- Scopepublic java.lang.String getValue()
public void setValue(java.lang.String value)
value
- Value to be formattedpublic boolean getReplaceSpToNbsp()
get
method of replaceSpToNbsp
conversion flagpublic void setReplaceSpToNbsp(boolean replaceSpToNbsp)
set
method of replaceSpToNbsp
replaceSpToNbsp
- Replace half-width space to
conversion flagpublic int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.JspException
- Error at the time of tag evaluationpublic void release()
release
in interface javax.servlet.jsp.tagext.Tag
release
in class javax.servlet.jsp.tagext.TagSupport
protected abstract java.lang.String doFormat(java.lang.String s)
s
- String to be formatted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |