net.ontopia.topicmaps.nav2.taglibs.tolog
Class ForEachTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by net.ontopia.topicmaps.nav2.taglibs.tolog.ForEachTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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

INTERNAL: Tolog Tag for executing a query, iterating over each object in a result collection and creating new content for each iteration. The column names in the query result are accessible as variables in the body of the tag, and are bound to the query result row of that iteration. The groupBy attribute can be used to indicate that only some of the column names should be bound (yet), and that only lines which differ in those columns should produce new output. To access those columns, one can use another ForEachTag nested within this one, which has no query attribute, but uses the result set produced here. The nested ForEachTag can group by columns not yet grouped. This can format a tree-result like the following (using a single query): Asia China Beijing Shanghai India Delhi Europe Sweden Gothenburg

See Also:
Serialized Form

Field Summary
protected static Collection FALSE
           
protected  String groupBy
           
protected  boolean[] groupColumns
           
protected  ForEachTag groupingAncestor
           
protected  Set groupNames
           
protected  boolean hasValidated
           
protected  boolean neverEvaluatedBody
           
protected  List orderBy
           
protected  String query
           
protected  QueryWrapper queryWrapper
           
protected  String separator
           
protected static String SEQUENCE_FIRST
           
protected static String SEQUENCE_LAST
           
protected static String SEQUENCE_NUMBER
           
protected  int sequenceNumber
           
protected static Collection TRUE
           
 
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 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
ForEachTag()
          Default constructor.
 
Method Summary
 int doAfterBody()
          Actions after some body has been evaluated.
 int doEndTag()
          Process the end tag.
 int doStartTag()
          Process the start tag for this instance.
protected  List getOrderBy()
          Get the names to order by in this tag (to be used by nested tags for ordering
protected  QueryWrapper getQueryWrapper()
           
 boolean needsCurrentRow()
          Checks if this ForEachTag needs the current row of the query result.
protected  void processGroupBy()
          Finds out which columns to group by based on a space separated string.
 void release()
          Resets the state of the Tag.
 void setGroupBy(String groupBy)
           
 void setQuery(String query)
           
 void setSeparator(String separator)
           
protected  void validateGroupByOrderBy()
          Validate the groupNames against the names in orderBy.
 
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, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

groupingAncestor

protected ForEachTag groupingAncestor

queryWrapper

protected QueryWrapper queryWrapper

groupColumns

protected boolean[] groupColumns

groupNames

protected Set groupNames

orderBy

protected List orderBy

hasValidated

protected boolean hasValidated

sequenceNumber

protected int sequenceNumber

neverEvaluatedBody

protected boolean neverEvaluatedBody

SEQUENCE_FIRST

protected static final String SEQUENCE_FIRST
See Also:
Constant Field Values

SEQUENCE_NUMBER

protected static final String SEQUENCE_NUMBER
See Also:
Constant Field Values

SEQUENCE_LAST

protected static final String SEQUENCE_LAST
See Also:
Constant Field Values

FALSE

protected static final Collection FALSE

TRUE

protected static final Collection TRUE

query

protected String query

groupBy

protected String groupBy

separator

protected String separator
Constructor Detail

ForEachTag

public ForEachTag()
Default constructor.

Method Detail

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspTagException
Process the start tag for this instance. Depending on the input, chooses between evaluating an input query or continuing iteration over a queryResult obtained in an ancestor ForEachTag. Binds any varibles needed in the body.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspTagException

getOrderBy

protected List getOrderBy()
Get the names to order by in this tag (to be used by nested tags for ordering


needsCurrentRow

public boolean needsCurrentRow()
Checks if this ForEachTag needs the current row of the query result.


processGroupBy

protected void processGroupBy()
                       throws javax.servlet.jsp.JspTagException
Finds out which columns to group by based on a space separated string.

Throws:
javax.servlet.jsp.JspTagException

validateGroupByOrderBy

protected void validateGroupByOrderBy()
                               throws javax.servlet.jsp.JspTagException
Validate the groupNames against the names in orderBy.

Throws:
javax.servlet.jsp.JspTagException

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspTagException
Actions after some body has been evaluated.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspTagException

getQueryWrapper

protected QueryWrapper getQueryWrapper()

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Process the end tag.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

release

public void release()
Resets the state of the Tag.

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

setSeparator

public void setSeparator(String separator)

setGroupBy

public void setGroupBy(String groupBy)

setQuery

public void setQuery(String query)


Copyright © 2000-2012 Ontopia.