jp.terasoluna.fw.web.taglib
Class WriteCodeValueTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by jp.terasoluna.fw.web.taglib.WriteCodeValueTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class WriteCodeValueTag
extends javax.servlet.jsp.tagext.TagSupport

WriteCodeValue tag.

From the servlet context, search the CodeListLoader which is specified in codeList attribute, fetch the value from the stored codelist and output the value. When it is not found, nothing is output.

To read the code list, refer to the implementation class of CodeListLoader interface. Attributes supported by tag

writeCodeValue tag supports the following attributes.

Attribute name Default value Required Execution time format Overview
codeList - true true Searches CodeListLoader from this attribute. In other words, specify the name of bean which implements CodeListLoader interface.
key - false true Directly specify the key to fetch the value from the retreived code list.
name - false true Name of the Bean that retains the key to fetch the value from the retrieved code list. It is invalid when key attribute is specified.
property - false true Property of Bean that retains the key to fetch the value from the retrieved code list. It is invalid when key attribute is specified.
scope - false true This is the scope in which Bean exists. The Bean retains the key to fetch the value from the retreived code list.

Scripting variable of custom tag

There is no scripting variable which is set by this tag.


How to use

In the following example, bean of the class that implements CodeListLoader ,is defined with the name as "loader1". The configuration example to fetch and output the value by using the key named as "key1" is also shown.
For the method of defining the bean, refer to DBCodeListLoader, and MappedCodeListLoader .

Description example in JSP.
  <t:writeCodeValue codeList="loader1" key="key1" />
 
To fetch the code list size, refer to WriteCodeCountTag.

See Also:
CodeListLoader, DBCodeListLoader, MappedCodeListLoader, DefineCodeListTag, WriteCodeCountTag, Serialized Form

Field Summary
private  java.lang.String codeList
          Code list name.
private  java.lang.String key
          Key to fetch the value from the code list.
private static org.apache.commons.logging.Log log
          Log class.
private  java.lang.String name
          Name of the Bean to retreive the value specified in property.
private  java.lang.String property
          Property name which is accessed in the Bean. This Bean is specified in name attribute.
private  java.lang.String scope
          Search scope to fetch the bean that is specified in name attribute.
private static long serialVersionUID
          Serial version ID
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, 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
WriteCodeValueTag()
           
 
Method Summary
 int doEndTag()
          Method which is called at the time of terminating the tag evaluation.
 int doStartTag()
          Method which is called at the time of starting the tag evaluation.
 void release()
          Process at the time of releasing the tag handler.
 void setCodeList(java.lang.String codeList)
          Sets the code list name.
 void setKey(java.lang.String key)
          Sets the key.
 void setName(java.lang.String name)
          Sets the Bean name.
 void setProperty(java.lang.String property)
          Sets the property name.
 void setScope(java.lang.String scope)
          Sets the scope.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial version ID

See Also:
Constant Field Values

log

private static org.apache.commons.logging.Log log
Log class.


codeList

private java.lang.String codeList
Code list name.


key

private java.lang.String key
Key to fetch the value from the code list.


name

private java.lang.String name
Bean name to fetch the value specified in property.


property

private java.lang.String property
Property name which is accessed in the Bean. This Bean is specified in name attribute.


scope

private java.lang.String scope
Search scope to fetch the bean which is specified in name attribute.

Constructor Detail

WriteCodeValueTag

public WriteCodeValueTag()
Method Detail

setName

public void setName(java.lang.String name)
Sets Bean name.

Parameters:
name - Bean name

setProperty

public void setProperty(java.lang.String property)
Sets property name.

Parameters:
property - Property name

setScope

public void setScope(java.lang.String scope)
Sets the scope.

Parameters:
scope - Scope

setKey

public void setKey(java.lang.String key)
Sets the key.

Parameters:
key - Code list key

setCodeList

public void setCodeList(java.lang.String codeList)
Sets the code list name.

Parameters:
codeList - Code list name

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Method which is called at the time of starting the tag evaluation.

From the servlet context, fetch the ApplicationContext. Fetch the CodeListLoader by the id which is specified in "codeList" attribute. Fetch the value from the code list and output the value. When the "key" attribute is specified, fetch the key value. When it is not specified, fetch the key from the bean which is specified in "name" attribute and use the key. When the code list is not found or when the key does not exist, nothing is output.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions. Always EVAL_BODY_INCLUDE
Throws:
javax.servlet.jsp.JspException - JSP exception

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Method which is called at the time of terminating the tag evaluation.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions. Always EVAL_PAGE
Throws:
javax.servlet.jsp.JspException - JSP exception

release

public void release()
Process at the time of releasing the tag handler.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport