jp.terasoluna.fw.web.taglib
Class DefineCodeListTag

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

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

Implementation class of defineCodeList tag.

From the servlet context, searches the CodeListLoader which is specified in id attribute. Fetches the code list stored in that CodeListLoader. When the code list not found, fetches the empty code list.

Since the property name of the elements in the code list, is stored in "id" and "name". These element names are used as property in the tag to access these elements. To load the code list, refer to the implementation class of CodeListLoader interface. Attribute supported by tag

In defineCodeList tag, following attributes are supported.

Attribute name Default value Required Execution time format Overview
id - true true Searches CodeListLoader using this attribute. Specify the name of bean in which CodeListLoader interface is implemented. After declaring this tag, code list can be referred in <logic:iterator> tag and <html:options> tag.

Scripting variable of custom tag

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


How to use

In the following configuration example, bean of the class that implements CodeListLoader interface, is defined with the name as "loader1" and used.
For the method of defining, refer to DBCodeListLoader, and MappedCodeListLoader.

Description example in JSP.
  <t:defineCodeList id="loader1" />
  ...
  <html:select property="selectOptions">
    <html:options collection="loader1"
                  labelProperty="name"
                  property="id"/>
  </html:select>
  ...
 
For retreiving the size of code list, refer to WriteCodeCountTag.

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

Field Summary
private static org.apache.commons.logging.Log log
          Log class.
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
DefineCodeListTag()
           
 
Method Summary
 int doEndTag()
          Method which is called at the time of terminating tag evaluation.
 int doStartTag()
          Method which is called at the time of starting tag evaluation.
 void release()
          Process at the time of releasing the tag handler.
 
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.

Constructor Detail

DefineCodeListTag

public DefineCodeListTag()
Method Detail

doStartTag

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

From the servlet context, fetches the ApplicationContext. Fetches CodeListLoader by using the id specified in "page" attribute. Registers the code list to the pageContext. When code list is not found, empty ArrayList is registered in the pageContext. The scope at the time of registration is "page".

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions. It is 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 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