Class ForEachTag
java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
jakarta.servlet.jsp.tagext.BodyTagSupport
net.ontopia.topicmaps.nav2.taglibs.tolog.ForEachTag
- All Implemented Interfaces:
jakarta.servlet.jsp.tagext.BodyTag,jakarta.servlet.jsp.tagext.IterationTag,jakarta.servlet.jsp.tagext.JspTag,jakarta.servlet.jsp.tagext.Tag,Serializable
public class ForEachTag
extends jakarta.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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Collectionprotected Stringprotected boolean[]protected ForEachTagprotected Setprotected booleanprotected booleanprotected Listprotected Stringprotected QueryWrapperprotected Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected intprotected static final CollectionFields inherited from class jakarta.servlet.jsp.tagext.BodyTagSupport
bodyContentFields inherited from class jakarta.servlet.jsp.tagext.TagSupport
id, pageContextFields inherited from interface jakarta.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFEREDFields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintActions after some body has been evaluated.intdoEndTag()Process the end tag.intProcess the start tag for this instance.protected ListGet the names to order by in this tag (to be used by nested tags for orderingprotected QueryWrapperbooleanChecks if this ForEachTag needs the current row of the query result.protected voidFinds out which columns to group by based on a space separated string.voidrelease()Resets the state of the Tag.voidsetGroupBy(String groupBy) voidvoidsetSeparator(String separator) protected voidValidate the groupNames against the names in orderBy.Methods inherited from class jakarta.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContentMethods inherited from class jakarta.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
-
Field Details
-
groupingAncestor
-
queryWrapper
-
groupColumns
protected boolean[] groupColumns -
groupNames
-
orderBy
-
hasValidated
protected boolean hasValidated -
sequenceNumber
protected int sequenceNumber -
neverEvaluatedBody
protected boolean neverEvaluatedBody -
SEQUENCE_FIRST
- See Also:
-
SEQUENCE_NUMBER
- See Also:
-
SEQUENCE_LAST
- See Also:
-
FALSE
-
TRUE
-
query
-
groupBy
-
separator
-
-
Constructor Details
-
ForEachTag
public ForEachTag()
-
-
Method Details
-
doStartTag
public int doStartTag() throws jakarta.servlet.jsp.JspTagExceptionProcess 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:
doStartTagin interfacejakarta.servlet.jsp.tagext.Tag- Overrides:
doStartTagin classjakarta.servlet.jsp.tagext.BodyTagSupport- Throws:
jakarta.servlet.jsp.JspTagException
-
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 jakarta.servlet.jsp.JspTagExceptionFinds out which columns to group by based on a space separated string.- Throws:
jakarta.servlet.jsp.JspTagException
-
validateGroupByOrderBy
protected void validateGroupByOrderBy() throws jakarta.servlet.jsp.JspTagExceptionValidate the groupNames against the names in orderBy.- Throws:
jakarta.servlet.jsp.JspTagException
-
doAfterBody
public int doAfterBody() throws jakarta.servlet.jsp.JspTagExceptionActions after some body has been evaluated.- Specified by:
doAfterBodyin interfacejakarta.servlet.jsp.tagext.IterationTag- Overrides:
doAfterBodyin classjakarta.servlet.jsp.tagext.BodyTagSupport- Throws:
jakarta.servlet.jsp.JspTagException
-
getQueryWrapper
-
doEndTag
public int doEndTag() throws jakarta.servlet.jsp.JspExceptionProcess the end tag.- Specified by:
doEndTagin interfacejakarta.servlet.jsp.tagext.Tag- Overrides:
doEndTagin classjakarta.servlet.jsp.tagext.BodyTagSupport- Throws:
jakarta.servlet.jsp.JspException
-
release
public void release()Resets the state of the Tag.- Specified by:
releasein interfacejakarta.servlet.jsp.tagext.Tag- Overrides:
releasein classjakarta.servlet.jsp.tagext.BodyTagSupport
-
setSeparator
-
setGroupBy
-
setQuery
-