org.apache.beehive.netui.tags.databinding.repeater
Class Repeater

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by Repeater
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, TryCatchFinally, IDataAccessProvider, INetuiTag

public class Repeater
extends AbstractClassicTag
implements IDataAccessProvider, TryCatchFinally

The <netui-data:repeater> tag is a markup-generic tag that repeats over a data set. The repeater tag set is used to render data from a data set into a page. The repeater itself does not render any markup. Instead, the markup from its contained tags is rendered to create the content generated by this tag. The tags in the repeater tag set are as follows:

TagDescription
RepeaterHeaderRenders once in the HEADER state.
RepeaterItemRenders once in the ITEM state.
RepeaterFooterRenders once in the FOOTER state.
PadUsed to convert irregular data sets into regular data sets through padding or truncating the output.

The repeater can render in two modes; the first mode is a simple mode where the body of the repeater is rendered once for each item in the data set. In this case, none of the other tags above are present in the repeater body. For example, the following will render an unordered HTML list of items that are list items which contain the lastName, firstName of the current "customer" in the data set.

 <ul>
 <netui-data:repeater dataSource="pageInput.customers">
     <li><netui:span value="${container.item.lastName}, ${container.item.firstName}"/></li>
 </netui-data:repeater>
 </ul>
 

The second mode is a more structured mode of rendering where the tags above are used to delineate iteration boundaries on the body of a <netui-data:repeater> tag. In this case, if one of the above tags is present, any content directly in the body of the repeater is not rendered; rather, the content inside the structured tags of the repeater is rendered.

For example, the following will render the same output as the example shown above, but it uses the structured tags for rendering the pageFlow.customers expression:

 <netui-data:repeater dataSource="pageInput.customers">
     <netui-data:repeaterHeader>
         <ul>
     </netui-data:repeaterHeader>
     <netui-data:repeaterItem>
         <li><netui:span value="${container.item.lastName}, ${container.item.firstName}"/></li>
     </netui-data:repeaterItem>
     <netui-data:repeaterFooter>
         </ul>
     </netui-data:repeaterFooter>
 </netui-data:repeater>
 

See Also:
Serialized Form
Example
The following sample renders the data set as an HTML table. The table has two columns, "index" and "name", and each iteration over the data set is rendered as a row of the table.

    <netui-data:repeater dataSource="pageInput.myDataSet">
        <netui-data:repeaterHeader>
            <table border="1">
                <tr>
                    <td><b>index</b></td>
                    <td><b>name</b></td>
                </tr>
        </netui-data:repeaterHeader>
        <netui-data:repeaterItem>
            <tr>
                <td>
                    <netui:span value="${container.index}" />
                </td>
                <td>
                    <netui: value="${container.item}" />
                </td>
            </tr>
        </netui-data:repeaterItem>
        <netui-data:repeaterFooter>
            </table>
        </netui-data:repeaterFooter>
    </netui-data:repeater>

Field Summary
static int END
          A Repeater rendering state that signals the end of repeater rendering.
static int FOOTER
          A Repeater rendering state that signals the rendering of the FOOTER.
static int HEADER
          A Repeater rendering state that signals the rendering of the HEADER.
static int INIT
          A Repeater rendering state that signals the beginning of repeater rendering.
static int ITEM
          A Repeater rendering state that signals the rendering of the ITEM.
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
Repeater()
           
 
Method Summary
 void addContent(String content)
          Add content to the content that is being buffered by this tag.
 int doAfterBody()
           Continue rendering the repeater changing the render state or advancing to a new data item as needed.
 void doCatch(Throwable t)
           
 int doEndTag()
          Complete rendering the repeater.
 void doFinally()
           
 int doStartTag()
          Start rendering the repeater.
 int getCurrentIndex()
          Get the index of the current iteration through the body of this tag.
 Object getCurrentItem()
          Get the item that is currently being rendered by this repeating tag.
 Object getCurrentMetadata()
          Get the metadata for the current item.
 String getDataSource()
          Gets the tag's data source (can be an expression).
protected  List getNamingChain()
          Return an ArrayList which represents a chain of INameInterceptor objects.
 IDataAccessProvider getProviderParent()
          Get the parent IDataAccessProvider for this tag.
 int getRenderState()
          Get the current render state for the repeater.
 String getTagName()
          Get the name of this tag.
protected  void localRelease()
          Reset all of the fields of this tag.
 void registerChildTag(RepeaterComponent repeaterComponent)
          Method used by tags in the repeater tag set to register the presence of a contained tag.
 void setDataSource(String dataSource)
          Sets the tag's data source (can be an expression).
 void setDefaultText(Object defaultText)
          Set the text that will be rendered if the dataSource expression references a null object and the defaultText attribute is non-null.
 void setIgnoreNulls(boolean ignoreNulls)
          Set a boolean that describes whether the repeater should ignore null items encountered while iterating over a data set.
 void setPadContext(PadContext padContext)
           
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNearestForm, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Field Detail

INIT

public static final int INIT
A Repeater rendering state that signals the beginning of repeater rendering.

See Also:
Constant Field Values

HEADER

public static final int HEADER
A Repeater rendering state that signals the rendering of the HEADER. The body renders in the HEADER state once.

See Also:
Constant Field Values

ITEM

public static final int ITEM
A Repeater rendering state that signals the rendering of the ITEM. The body renders in the ITEM state once for each item in the data set.

See Also:
Constant Field Values

FOOTER

public static final int FOOTER
A Repeater rendering state that signals the rendering of the FOOTER. The body renders in the FOOTER state once.

See Also:
Constant Field Values

END

public static final int END
A Repeater rendering state that signals the end of repeater rendering.

See Also:
Constant Field Values
Constructor Detail

Repeater

public Repeater()
Method Detail

getTagName

public String getTagName()
Get the name of this tag. This is used to identify the type of this tag for reporting tag errors.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
a constant String representing the name of this tag.

setIgnoreNulls

public void setIgnoreNulls(boolean ignoreNulls)
Set a boolean that describes whether the repeater should ignore null items encountered while iterating over a data set.

Parameters:
ignoreNulls - whether or not to ignore nulls

setPadContext

public void setPadContext(PadContext padContext)
Parameters:
padContext -

setDefaultText

public void setDefaultText(Object defaultText)
Set the text that will be rendered if the dataSource expression references a null object and the defaultText attribute is non-null.

Parameters:
defaultText - the default text

getCurrentIndex

public int getCurrentIndex()
Get the index of the current iteration through the body of this tag. This data can be accessed using the expression container.index on an attribute of a databindable NetUI tag that is contained within the repeating body of this tag. This expression is only valid when the dataset is being rendered.

Specified by:
getCurrentIndex in interface IDataAccessProvider
Returns:
the integer index of the current data item in the data set
See Also:
IDataAccessProvider

getCurrentItem

public Object getCurrentItem()
Get the item that is currently being rendered by this repeating tag. This can be accessed using the expression expression.item on an attribute of a databindable NetUI tag that is contained within the repeating body of this tag. The expression is only valid when the dataset is being rendered.

Specified by:
getCurrentItem in interface IDataAccessProvider
Returns:
the current item in the data set
See Also:
IDataAccessProvider

getCurrentMetadata

public Object getCurrentMetadata()
Get the metadata for the current item. This method is not supported by this tag.

Specified by:
getCurrentMetadata in interface IDataAccessProvider
Returns:
the current metadata or null if no metadata can be found or metadata is not supported by a IDataAccessProvider implementation
Throws:
UnsupportedOperationException - this tag does not support this method from the IDataAccessProvider interface
See Also:
IDataAccessProvider

getProviderParent

public IDataAccessProvider getProviderParent()
Get the parent IDataAccessProvider for this tag. If this tag is contained within a IDataAccessProvider, the containing IDataAccessProvider is available through the expression container.container. Any valid properties of the parent IDataAccessProvider can be accessed through this expression. This method will return null if there is no parent IDataAccessProvider

Specified by:
getProviderParent in interface IDataAccessProvider
Returns:
a containing IDataAccessProvider if one exists, null otherwise.
See Also:
IDataAccessProvider

getRenderState

public int getRenderState()
Get the current render state for the repeater. This tag is used by child tags to access the current location in the repeater's rendering lifecycle.

Returns:
an integer that represents the current state of the grid; this is one of INIT, HEADER, ITEM,FOOTER, or END.

addContent

public void addContent(String content)
Add content to the content that is being buffered by this tag. All content written by the body of this tag is added to this buffer. The buffer is rendered at the end of the tag's lifecycle if no fatal errors have occurred during this tag's lifecycle.

Parameters:
content - content that this tag should render.

registerChildTag

public void registerChildTag(RepeaterComponent repeaterComponent)
Method used by tags in the repeater tag set to register the presence of a contained tag. When registered, the repeater will change the way in which it renders to either use structured or non-structured rendering.

Parameters:
repeaterComponent - RepeaterComponent to register with the Repeater parent

doStartTag

public int doStartTag()
               throws JspException
Start rendering the repeater.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Returns:
Tag.SKIP_BODY if an error occurs; BodyTag.EVAL_BODY_BUFFERED otherwise
Throws:
JspException - if an error occurs that can not be reported in the page

doAfterBody

public int doAfterBody()

Continue rendering the repeater changing the render state or advancing to a new data item as needed.

Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class BodyTagSupport
Returns:
Tag.SKIP_BODY if an error occurs or the data set has been rendered; IterationTag.EVAL_BODY_AGAIN otherwise

doEndTag

public int doEndTag()
             throws JspException
Complete rendering the repeater.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Returns:
Tag.EVAL_PAGE
Throws:
JspException - if an error occurs that can not be reported in the page

doFinally

public void doFinally()
Specified by:
doFinally in interface TryCatchFinally

doCatch

public void doCatch(Throwable t)
             throws Throwable
Specified by:
doCatch in interface TryCatchFinally
Throws:
Throwable

localRelease

protected void localRelease()
Reset all of the fields of this tag.

Overrides:
localRelease in class AbstractClassicTag

getNamingChain

protected List getNamingChain()
Return an ArrayList which represents a chain of INameInterceptor objects. This method by default returns null and should be overridden by objects that support naming.

Overrides:
getNamingChain in class AbstractClassicTag
Returns:
an ArrayList that will contain INameInterceptor objects.

setDataSource

public void setDataSource(String dataSource)
Sets the tag's data source (can be an expression).

Parameters:
dataSource - - the data source

getDataSource

public String getDataSource()
Gets the tag's data source (can be an expression).

Specified by:
getDataSource in interface IDataAccessProvider
Returns:
the data source