Display *: Tag Library

The display tag library is an open source suite of custom tags that provide high level web presentation patterns which will work in a MVC model, and provide a significant amount of functionality while still being simple and straight-forward to use. The primary tag in the library is the Table tag. This is version 1.0-rc1 .

  • table Displays a list in an html table, formatting each item in the list according to the Column tags nested inside of this tag .
  • column Displays a property of a row object inside a table .
  • setProperty Sets the indicated property on the enclosing Table tag .
  • footer Tag wich should be nested into a table tag to provide a custom table footer .
  • caption Simple tag which mimics the html caption tag .

Required attributes are marked with a * .

table

Displays a list in an html table, formatting each item in the list according to the Column tags nested inside of this tag. Use the list attribute to indicate the Collection of data, in some scope, that the tag should operate on. Supports the export of the list data to alternative formats such as CSV, Excel, and XML. The contents of the list can be sorted, and the list can be broken into individual pages for display. If you use this tag in Struts, or in some other framework where the page is included via a jsp:include, you should use the requestURI attribute to indicate where tag generated links should point.

Can contain: JSP

Example

 
<display:table name="someList" export="true" id="row" requestURI="MyAction.do">
  <display:column sortable="true" title="ID"> <c:out value="${row.id}"/> </display:column>
  <display:column property="email" autolink="true"/>
  <display:column property="description" title="Comments"/>
</display:table>
 

Attributes

NameDescriptionType
cellpaddinghtml pass through attribute. Better using "padding" css attribute in style or classString
cellspacinghtml pass through attributeString
classhtml pass through attributeString
decoratorFully qualified class name for a TableDecorator. Use a TableDecorator to provide custom operations against the whole list, such as computing totals. Must extend org.displaytag.decorator.TableDecorator. String
defaultorderThe default order for the sorted column. Valid values are "ascending" (default) or "descending"String
defaultsortThe index of the column that will be used by default for sorting (starting from 1)int
exportenable/disable export. Valid values are true or false boolean
framehtml pass through attribute.String
idAn implicit variable of this name will be created and placed into NESTED scope. The object is also added to pageContext under this name.String
lengthnumber of records to be shownString
listReference to the object used as source for the table. Can be an expression like requestScope.object.property . You must define either the name attribute or the list attribute. List is suggested.String
namereference to the object used as source for the table. Can be an expression like requestScope.object.property. In the EL version of the taglibrary this must be an EL expression which points to the source object. String
offsetindex of the first record to be shownString
pagesizenumber of records in a pageString
requestURIWhen the present, links for sorting, exports, and paging are formed by adding any tag generated parameters to the value of requestURI attribute.String
ruleshtml pass through attribute. String
sortUse 'page' if you want to sort only visible records, or 'list' if you want to sort the full listString
stylehtml pass through attributeString
summaryhtml pass through attributeString
styleClass@deprecated: use "class"String
align@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
background@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
bgcolor@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
height@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
hspace@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
vspace@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
width@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
border@deprecated html pass through attribute. Use css "border"String
scope@deprecated in displaytag 1.0. Use "pageScope.", "requestScope.", "sessionScope.", "applicationScope." prefixes in name. Not supported in the EL version of the tag.String
property@deprecated in displaytag 1.0. Use list.property in "name" attribute. Not supported in the EL version of the tag.String

column

Displays a property of a row object inside a table. MUST be nested inside of a Table tag. The value displayed will be the results of a decorator (if any); else the property named by the 'property' attribute; or if the 'property' attribute is null, then the results of evaluating the JSP body of the tag.

Can contain: JSP

Attributes

NameDescriptionType
autolinkAutomatically hyperlink URLs and email addresses that appear in the column. Defaults to 'false'.boolean
classhtml pass through attribute; use this instead of directly coding presentational atttributes.String
decoratorThe fully qualified class name of a class that should be used to "decorate" the underlying object being displayed. The class should implement org.displaytag.decorator.ColumnDecorator. If a decorator is specified for the entire table, then this decorator will decorate that decorator. String
group The grouping level (starting at 1 and incrementing) of this column (indicates if successive contain the same values, then they should not be displayed). The level indicates that if a lower level no longer matches, then the matching for this higher level should start over as well. If this attribute is not included, then no grouping is performed. int
headerClass"class" html attribute added only for header cells.String
hrefThe base URL used to construct the dynamic link. If this attribute is provided, then the data that is shown for this column is wrapped inside a <a href> tag with the url provided through this attribute. Typically you would use this attribute along with one of the struts-like param attributes (param*) to create a dynamic link so that each row creates a different URL based on the data that is being viewed. String
maxLength If this attribute is provided, then the column's displayed is limited to this number of characters. An elipse (...) is appended to the end if this column is linked, and the user can mouseover the elipse to get the full text. String
maxWords If this attribute is provided, then the column's displayed is limited to this number of words. An elipse (...) is appended to the end if this column is linked, and the user can mouseover the elipse to get the full text. String
mediaUse this attribute to keep a column from being output during an export. The column will only render for the named media type(s) - it won't be added to the table if the current request media is not supported. Can be any space separated combination of 'html', 'csv', 'xml', 'all', or 'excel'. Defaults to 'all'. See the export page in the example webapp for more details.String
nullsBy default, null values don't appear in the list. By setting 'nulls' to 'true', then null values will appear as "null" in the list (mostly useful for debugging). Defaults to 'false'. boolean
paramId The name of the request parameter that will be dynamically added to the generated href URL. The corresponding value is defined by the paramProperty and (optional) paramName attributes, optionally scoped by the paramScope attribute. String
paramName The name of a JSP bean that is a String containing the value for the request parameter named by paramId (if paramProperty is not specified), or a JSP bean whose property getter is called to return a String (if paramProperty is specified). The JSP bean is constrained to the bean scope specified by the paramScope property, if it is specified. If paramName is omitted, then it is assumed that the current object being iterated on is the target bean. String
paramProperty The name of a property of the current object being iterated on, whose return value will be used as the value of the parameter (named by the paramId attribute) that will be dynamically added to this href URL. If paramName is also specified the property will not be fetched from the object being iterated on, but from the bean specified by paramName. The support of paramProperty in conjunction with paramName will be probably removed in future: use paramProperty only if you need a property in the iterated object, elsewhere use only paramName (you can select a property using an expression name.property). String
propertyname of the property in the bean specified in the parent table tag (via the "name" attribute) mapped to this columnString
sortableSet to 'true' to make the column sortable. Defaults to 'false'.boolean
stylehtml pass through attribute.String
titletitle of the column (text for the th cell)String
urlThe base URL used to construct the dynamic link. This attribute has the same functionality as the href attribute, but it pre-pends the contextPath. String
width@deprecated; html attribute. Use "style" or "class" to set presentational attributes using css.String
styleClass@deprecated: use "class"String
headerStyleClass@deprecated: use "headerClass"String
sort@deprecated: use "sortable"String
align@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
background@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
bgcolor@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
height@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
nowrap@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
valign@deprecated html attribute. Use "style" or "class" to set presentational attributes using css.String
paramScope @deprecated - use Expressions in paramName. The scope within which to search for the bean specified by the paramName attribute. If not specified, all scopes are searched. If paramName is not provided, then the current object being iterated on is assumed to be the target bean. String

setProperty

Sets the indicated property on the enclosing Table tag. MUST be nested within a Table tag. As an alternative, you may create a property file that holds sitewide defaults; see the configuration documentation or the DisplayPropertiesLoaderServlet javadoc for information.

Can contain: JSP

Example

 
<display:setProperty name="paging.banner.placement" value="bottom" />
or
<display:setProperty name="paging.banner.placement">bottom</display:setProperty>
 

Attributes

NameDescriptionType
*nameThe name of the property to set on the enclosing Table tag.String
valueThe value to which the property is set. You can also set the property value in the tag body.String

footer

Tag wich should be nested into a table tag to provide a custom table footer. The body of the tag is outputted as is in the generated table in the tfoot section.

Can contain: JSP

Example

 
<display:table name="someList">
  <display:column property="mail"/>
  <display:column property="total"/>
  <display:footer>
  	<tr>
  		<td>total:</td>
  		<td><c:out value="${something}" /></td>
  	<tr>
  </display:footer>
</display:table>
 

Attributes

This tag has no attributes.

caption

Simple tag which mimics the html caption tag. Use it inside a table tag to display a caption.

Can contain: JSP

Example

 
<display:table name="someList">
  <display:column property="mail"/>
  <display:column property="total"/>
  <display:caption>This is the table caption</display:caption>
</display:table>
 

Attributes

NameDescriptionType
classhtml pass through attribute.String
dirhtml pass through attribute.String
idhtml pass through attribute.String
langhtml pass through attribute.String
stylehtml pass through attribute.String
titlehtml pass through attribute.String