com.ora.jsp.tags.generic
Class LoopTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--com.ora.jsp.tags.generic.LoopTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class LoopTag
extends javax.servlet.jsp.tagext.BodyTagSupport

This class is a custom action for looping through the elements of a multi-valued bean or bean property. The bean or bean property must be an array, a Vector, a Dictionary or an Enumeration. The action body is evaluated once for each element.

Version:
1.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  java.lang.String className
           
private  java.util.Enumeration enum
           
private  java.lang.String loopId
           
private  java.lang.String name
           
private  java.lang.String property
           
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext, parent, values
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
LoopTag()
           
 
Method Summary
 int doAfterBody()
          Makes the next element available to the body in a variable with the name specified by the loopId attribute, or returns SKIP_BODY if all elements have been processed.
 int doEndTag()
          Writes the accumulated body contents to the JspWriter.
 int doStartTag()
          Creates an Enumeration of all loop values, either using the object specified by the name attribute directly, or using the specified property.
private  java.util.Enumeration getEnumeration(java.lang.Object obj)
          Returns an Enumeration of the values in the specified multi-value object, which can be an Enumeration, Vector, Dictionary or array of Objects (not primitive types).
private  java.lang.Object getProperty(java.lang.Object obj, java.lang.String property)
          Returns an Object representing an Enumeration, a Vector, a Dictionary or an array of objects (no primitive types), using the specified property getter method on the specified object.
 void release()
          Releases all instance variables.
 void setClassName(java.lang.String className)
          Sets the class attribute, i.e.
 void setLoopId(java.lang.String loopId)
          Sets the loopId attribute, i.e.
 void setName(java.lang.String name)
          Sets the name attribute, i.e.
 void setProperty(java.lang.String property)
          Sets the property attribute, i.e.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

name

private java.lang.String name

property

private java.lang.String property

loopId

private java.lang.String loopId

className

private java.lang.String className

enum

private java.util.Enumeration enum
Constructor Detail

LoopTag

public LoopTag()
Method Detail

setName

public void setName(java.lang.String name)
Sets the name attribute, i.e. the name of the variable holding a reference to the bean with the multi-value property to loop through.
Parameters:
name - the bean variable name

setProperty

public void setProperty(java.lang.String property)
Sets the property attribute, i.e. the name of the multi-value property to loop through.
Parameters:
property - the property name

setLoopId

public void setLoopId(java.lang.String loopId)
Sets the loopId attribute, i.e. the name of the variable to hold the element reference in the body.
Parameters:
property - the property name

setClassName

public void setClassName(java.lang.String className)
Sets the class attribute, i.e. the name of the class for the multi-value property elements.
Parameters:
class - the element class name

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Creates an Enumeration of all loop values, either using the object specified by the name attribute directly, or using the specified property. The object or the property must be one of Enumeration, Vector, Dictionary or Object[] (no primitive type arrays), or a subclass/subinterface of one of them. Makes the first element available to the body in a variable with the name specified by the loopId attribute.
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Makes the next element available to the body in a variable with the name specified by the loopId attribute, or returns SKIP_BODY if all elements have been processed.
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Writes the accumulated body contents to the JspWriter.
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport

release

public void release()
Releases all instance variables.
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

getProperty

private java.lang.Object getProperty(java.lang.Object obj,
                                     java.lang.String property)
                              throws javax.servlet.jsp.JspException
Returns an Object representing an Enumeration, a Vector, a Dictionary or an array of objects (no primitive types), using the specified property getter method on the specified object.
Parameters:
obj - the Object with the multi-value property
property - the property name
Returns:
the multi-value Object

getEnumeration

private java.util.Enumeration getEnumeration(java.lang.Object obj)
                                      throws javax.servlet.jsp.JspException
Returns an Enumeration of the values in the specified multi-value object, which can be an Enumeration, Vector, Dictionary or array of Objects (not primitive types).
Parameters:
obj - the multi-value Object
Returns:
an Enumeration
Throws:
javax.servlet.jsp.JspException - if invalid type