org.displaytag.tags
Class TableTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended byorg.displaytag.tags.TemplateTag
              extended byorg.displaytag.tags.HtmlTableTag
                  extended byorg.displaytag.tags.TableTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
ELTableTag

public class TableTag
extends HtmlTableTag

This tag takes a list of objects and creates a table to display those objects. With the help of column tags, you simply provide the name of properties (get Methods) that are called against the objects in your list that gets displayed. This tag works very much like the struts iterator tag, most of the attributes have the same name and functionality as the struts tag.

Version:
$Revision: 1.99 $ ($Author: fgiust $)
Author:
mraible, Fabrizio Giustina
See Also:
Serialized Form

Field Summary
static java.lang.String FILTER_CONTENT_OVERRIDE_BODY
          If this variable is found in the request, assume the export filter is enabled.
protected  java.lang.Object list
          Object (collection, list) on which the table is based.
protected  java.lang.Object listAttribute
          Object (collection, list) on which the table is based.
static java.lang.String PAGE_ATTRIBUTE_MEDIA
          name of the attribute added to page scope when exporting, containing an MediaTypeEnum this can be used in column content to detect the output type and to return different data when exporting.
 
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
TableTag()
           
 
Method Summary
 void addCell(Cell cell)
          Adds a cell to the current row.
 void addColumn(HeaderCell column)
          Called by interior column tags to help this tag figure out how it is supposed to display the information in the List it is supposed to display.
 int doAfterBody()
           
 int doEndTag()
          Draw the table.
protected  int doExport()
          Called when data are not displayed in a html page but should be exported.
protected  int doIteration()
          Utility method that is used by both doStartTag() and doAfterBody() to perform an iteration.
 int doStartTag()
          When the tag starts, we just initialize some of our variables, and do a little bit of error checking to make sure that the user is not trying to give us parameters that we don't expect.
protected  Href getBaseHref()
          Returns the base href with parameters.
 java.lang.String getName()
          Returns the name.
 javax.servlet.jsp.PageContext getPageContext()
          It's a getter.
protected  TableProperties getProperties()
          Returns the properties.
 java.lang.String getUid()
          Returns the unique id used to identify for this table.
protected  void initHref(RequestHelper requestHelper)
          init the href object used to generate all the links for pagination, sorting, exporting.
protected  boolean isEmpty()
          Is the current row empty?
protected  boolean isFirstIteration()
          Is this the first iteration?
protected  boolean isIncludedRow()
          Is the current row included in the "to-be-evaluated" range?
 void release()
           
 void setCaption(java.lang.String string)
          Sets the content of the caption.
 void setDecorator(java.lang.String decorator)
          Setter for the decorator class name.
 void setDefaultorder(java.lang.String value)
          sets the sorting order for the sorted column.
 void setDefaultsort(int value)
          sets the index of the default sorted column.
 void setExcludedParams(java.lang.String value)
          Sets the list of parameter which should not be forwarded during sorting or pagination.
 void setExport(boolean value)
          Is export enabled?
 void setFooter(java.lang.String string)
          Sets the content of the footer.
 void setLength(int value)
          sets the number of items to be displayed in the page.
 void setList(java.lang.Object value)
          Deprecated. use setName() to get the object from the page or request scope instead of setting it directly here
 void setName(java.lang.Object value)
          Sets the name of the object to use for iteration.
 void setNameString(java.lang.String value)
          Sets the name of the object to use for iteration.
 void setOffset(int value)
          Setter for the list offset attribute.
 void setPagesize(int value)
          sets the number of items that should be displayed for a single page.
 void setProperty(java.lang.String value)
          Deprecated. Use expressions in "name" attribute
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Called by the setProperty tag to override some default behavior or text String.
 void setRequestURI(java.lang.String value)
          setter for the "requestURI" attribute.
 void setRequestURIcontext(boolean value)
          Setter for the "requestURIcontext" attribute.
 void setScope(java.lang.String value)
          Deprecated. Use expressions in "name" attribute
 void setSort(java.lang.String value)
          setter for the "sort" attribute.
 void setUid(java.lang.String value)
          Sets the unique id used to identify for this table.
protected  void setupViewableData()
          This sets the list of all of the data that will be displayed on the page via the table tag.
protected  void writeExport(ExportView exportView)
          Will write the export.
 
Methods inherited from class org.displaytag.tags.HtmlTableTag
addClass, getCloseTag, getHtmlId, getOpenTag, setAlign, setBackground, setBgcolor, setBorder, setCellpadding, setCellspacing, setClass, setFrame, setHeight, setHspace, setHtmlId, setRules, setStyle, setStyleClass, setSummary, setVspace, setWidth
 
Methods inherited from class org.displaytag.tags.TemplateTag
evaluateExpression, write, write, write
 
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

PAGE_ATTRIBUTE_MEDIA

public static final java.lang.String PAGE_ATTRIBUTE_MEDIA
name of the attribute added to page scope when exporting, containing an MediaTypeEnum this can be used in column content to detect the output type and to return different data when exporting.

See Also:
Constant Field Values

FILTER_CONTENT_OVERRIDE_BODY

public static final java.lang.String FILTER_CONTENT_OVERRIDE_BODY
If this variable is found in the request, assume the export filter is enabled.

See Also:
Constant Field Values

list

protected java.lang.Object list
Object (collection, list) on which the table is based. This is not set directly using a tag attribute and can be cleaned.


listAttribute

protected java.lang.Object listAttribute
Object (collection, list) on which the table is based. Set directly using the "list" attribute or evaluated from expression.

Constructor Detail

TableTag

public TableTag()
Method Detail

setExcludedParams

public void setExcludedParams(java.lang.String value)
Sets the list of parameter which should not be forwarded during sorting or pagination.

Parameters:
value - whitespace separated list of parameters which should not be included (* matches all parameters)

setFooter

public void setFooter(java.lang.String string)
Sets the content of the footer. Called by a nested footer tag.

Parameters:
string - footer content

setCaption

public void setCaption(java.lang.String string)
Sets the content of the caption. Called by a nested caption tag.

Parameters:
string - caption content

isEmpty

protected boolean isEmpty()
Is the current row empty?

Returns:
true if the current row is empty

setSort

public void setSort(java.lang.String value)
             throws InvalidTagAttributeValueException
setter for the "sort" attribute.

Parameters:
value - "page" (sort a single page) or "list" (sort the full list)
Throws:
InvalidTagAttributeValueException - if value is not "page" or "list"

setRequestURI

public void setRequestURI(java.lang.String value)
setter for the "requestURI" attribute. Context path is automatically added to path starting with "/".

Parameters:
value - base URI for creating links

setRequestURIcontext

public void setRequestURIcontext(boolean value)
Setter for the "requestURIcontext" attribute.

Parameters:
value - base URI for creating links

setList

public void setList(java.lang.Object value)
Deprecated. use setName() to get the object from the page or request scope instead of setting it directly here

Used to directly set a list (or any object you can iterate on).

Parameters:
value - Object

setName

public void setName(java.lang.Object value)
Sets the name of the object to use for iteration.

Parameters:
value - name of the object to use for iteration (can contain expression). It also supports direct setting of a list, for jsp 2.0 containers where users can set up a data source here using EL expressions.

setNameString

public void setNameString(java.lang.String value)
Sets the name of the object to use for iteration. This setter is needed for jsp 1.1 container which doesn't support the String - Object conversion. The bean info class will swith to this setter.

Parameters:
value - name of the object

setProperty

public void setProperty(java.lang.String value)
Deprecated. Use expressions in "name" attribute

Sets the property to get into the bean defined by "name".

Parameters:
value - property name

setDefaultorder

public void setDefaultorder(java.lang.String value)
                     throws InvalidTagAttributeValueException
sets the sorting order for the sorted column.

Parameters:
value - "ascending" or "descending"
Throws:
InvalidTagAttributeValueException - if value is not one of "ascending" or "descending"

setScope

public void setScope(java.lang.String value)
Deprecated. Use expressions in "name" attribute

Setter for object scope.

Parameters:
value - String

setDecorator

public void setDecorator(java.lang.String decorator)
Setter for the decorator class name.

Parameters:
decorator - fully qualified name of the table decorator to use

setExport

public void setExport(boolean value)
Is export enabled?

Parameters:
value - true if export should be enabled

setLength

public void setLength(int value)
sets the number of items to be displayed in the page.

Parameters:
value - number of items to display in a page

setDefaultsort

public void setDefaultsort(int value)
sets the index of the default sorted column.

Parameters:
value - index of the column to sort

setPagesize

public void setPagesize(int value)
sets the number of items that should be displayed for a single page.

Parameters:
value - number of items that should be displayed for a single page

setOffset

public void setOffset(int value)
Setter for the list offset attribute.

Parameters:
value - String

setUid

public void setUid(java.lang.String value)
Sets the unique id used to identify for this table.

Parameters:
value - String

getUid

public java.lang.String getUid()
Returns the unique id used to identify for this table.

Returns:
id for this table

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
It's a getter.

Returns:
the this.pageContext

getProperties

protected TableProperties getProperties()
Returns the properties.

Returns:
TableProperties

getBaseHref

protected Href getBaseHref()
Returns the base href with parameters. This is the instance used for links, need to be cloned before being modified.

Returns:
base Href with parameters

addColumn

public void addColumn(HeaderCell column)
Called by interior column tags to help this tag figure out how it is supposed to display the information in the List it is supposed to display.

Parameters:
column - an internal tag describing a column in this tableview

addCell

public void addCell(Cell cell)
Adds a cell to the current row. This method is usually called by a contained ColumnTag

Parameters:
cell - Cell to add to the current row

isFirstIteration

protected boolean isFirstIteration()
Is this the first iteration?

Returns:
boolean true if this is the first iteration

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
When the tag starts, we just initialize some of our variables, and do a little bit of error checking to make sure that the user is not trying to give us parameters that we don't expect.

Returns:
int
Throws:
javax.servlet.jsp.JspException - generic exception
See Also:
Tag.doStartTag()

doAfterBody

public int doAfterBody()
See Also:
IterationTag.doAfterBody()

doIteration

protected int doIteration()
Utility method that is used by both doStartTag() and doAfterBody() to perform an iteration.

Returns:
int either EVAL_BODY_TAG or SKIP_BODY depending on whether another iteration is desired.

isIncludedRow

protected boolean isIncludedRow()
Is the current row included in the "to-be-evaluated" range? Called by nested ColumnTags. If false column body is skipped.

Returns:
true if the current row must be evaluated because is included in output or because is included in sorting.

initHref

protected void initHref(RequestHelper requestHelper)
init the href object used to generate all the links for pagination, sorting, exporting.

Parameters:
requestHelper - request helper used to extract the base Href

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Draw the table. This is where everything happens, we figure out what values we are supposed to be showing, we figure out how we are supposed to be showing them, then we draw them.

Returns:
int
Throws:
javax.servlet.jsp.JspException - generic exception
See Also:
Tag.doEndTag()

doExport

protected int doExport()
                throws javax.servlet.jsp.JspException
Called when data are not displayed in a html page but should be exported.

Returns:
int SKIP_PAGE
Throws:
javax.servlet.jsp.JspException - generic exception

writeExport

protected void writeExport(ExportView exportView)
                    throws java.io.IOException,
                           javax.servlet.jsp.JspException
Will write the export. The default behavior is to write directly to the response. If the ResponseOverrideFilter is configured for this request, will instead write the exported content to a map in the Request object.

Parameters:
exportView - export view
Throws:
javax.servlet.jsp.JspException - for problem in clearing the response or for invalid export views
java.io.IOException - exception thrown when writing content to the response

setupViewableData

protected void setupViewableData()
This sets the list of all of the data that will be displayed on the page via the table tag. This might include just a subset of the total data in the list due to to paging being active, or the user asking us to just show a subset, etc...


setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String propertyValue)
Called by the setProperty tag to override some default behavior or text String.

Parameters:
propertyName - String property name
propertyValue - String property value

release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class HtmlTableTag
See Also:
Tag.release()

getName

public java.lang.String getName()
Returns the name.

Returns:
String


Copyright © 2002-2005 the Displaytag team. All Rights Reserved.