Display Tag

Embed Size (px)

Citation preview

......................................................................................................................................Display tag library v.1.0Project Documentation......................................................................................................................................displaytag 01 January 2005 17:55Table of Contents......................................................................................................................................T A B L E O F C O N T E N T Si 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D1Overview1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Reference2.1 Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Tlds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72.4 Tag reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.5 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.6 Export filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Tutorial3.1 Basic usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.2 Implicit objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.3 Data sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.4 Decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.5 Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.6 Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.7 Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.8 I18n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394Feedback4.1 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.2 Reporting bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464.3 Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485Developers5.1 Source Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.2 Building from sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.3 Directory Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52T A B L E O F C O N T E N T Sii 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D1.1Introduction......................................................................................................................................Overview1he display tag library is an open source suite o custom tags that proide high-leel web presentationpatterns which will work in an MVC model. 1he library proides a signiicant amount o unctionalitywhile still being easy to use.What can I do with it?Actually the display tag library can just... display tables! Gie it a list o objects and it will handle columndisplay, sorting, paging, cropping, grouping, exporting, smart linking and decoration o a table in acustomizable Xl1ML style.1he tables in the sample images below were generated rom lists using the display:table tag:1 . 1 I N T R O D U C T I O N1 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D1.2Dependencies......................................................................................................................................Dependencies1he ollowing is a list o dependencies or this project. 1hese dependencies are required to compile orrun the application. Most o the libraries listed here are actually needed only at build time or during tests,mainly or ramework integration tests, and you should not worry about them.Required at runtimeArtifact ID Type Version URL/commentscommons-beanutils jar 1.6.1 http://jakarta.apache.org/commons/beanutils...........................................................................................................................................................................................commons-collections jar 2.1.1 http://jakarta.apache.org/commons/collections also 3.0 is supported............................................................................................................................................................................................commons-lang jar 2.0 http://jakarta.apache.org/commons/lang commons-lang 1.0 will notwork...........................................................................................................................................................................................commons-logging jar 1.0.4 http://jakarta.apache.org/commons/loggingRequired for the EL versionArtifact ID Type Version URL/commentsjstl jar 1.0.2 http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/...........................................................................................................................................................................................standard jar 1.0.4 http://jakarta.apache.org/taglibs/Optional (and needed for compiling)Artifact ID Type Version URL/commentsitext jar 0.99 http://prdownloads.sourceforge.net/itext/ Needed at build time tocompile classes for the PDF export. Needed at runtime to enable PDFexport.Only required to build or to run unit tests1 . 2 D E P E N D E N C I E S2 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DArtifact ID Type Version URL/commentsportlet-api jar unknown http://jakarta.apache.org/jetspeed/site/install.html Required to buildjetspeed/websphere portal server support classes. Not needed atruntime............................................................................................................................................................................................log4j jar 1.2.8 http://logging.apache.org/log4j/docs/index.html optional: you can useany logging framework supported by commons-logging...........................................................................................................................................................................................maven-taglib-plugin plugin 1.2 http://maven-taglib.sourceforge.net maven plugin needed to generatetag reference documentation page and to generate the 1.1 version ofthe tld...........................................................................................................................................................................................servletapi jar 2.3 Servlet 2.3 support is required to build the library. At runtime onlyservlet 2.2 (tomcat 3, websphere 4) is strictly needed, servlet 2.3support (tomcat 4, websphere 5) is needed only for the EL version ofthe taglib...........................................................................................................................................................................................httpunit jar 1.6 http://httpunit.sourceforge.net Needed to compile and run HttpUnittests............................................................................................................................................................................................jtidy jar 4aug2000r7-dev http://jtidy.sourceforge.net Needed to run HttpUnit tests............................................................................................................................................................................................nekohtml jar 0.9.1 Needed to run HttpUnit tests............................................................................................................................................................................................js jar 1.5R4.1 Needed to run HttpUnit tests............................................................................................................................................................................................jasper-compiler jar 4.0.4 Needed to run HttpUnit tests............................................................................................................................................................................................jasper-runtime jar 4.0.4 Needed to run HttpUnit tests............................................................................................................................................................................................xerces jar 2.4.0 Needed to run HttpUnit tests............................................................................................................................................................................................xml-apis jar 1.0.b2 Needed to run HttpUnit tests............................................................................................................................................................................................tools jar 1.3 http://java.sun.com/j2se/1.4.2/download.html Needed to run HttpUnittests. This is the tools.jar from sun jdk. Jar in not in maven repositorybut is set to JAVA_HOME/../lib/tools.jar in project.properties...........................................................................................................................................................................................Struts jar 1.2.4 http://struts.apache.org/ Required to build Struts i18n adapter.Required at runtime only if you use Struts (if you wish to use it youshould already have Struts in your project)...........................................................................................................................................................................................Spring jar 1.1.1 http://www.springframework.org/ Required to build Spring i18nadapter. Required at runtime only if you use Spring (if you wish to useit you should already have Spring in your project)...........................................................................................................................................................................................commons-digester jar 1.4.1 http://jakarta.apache.org/commons/digester Struts dependencyneeded to run Struts integration tests............................................................................................................................................................................................webwork jar 2.1.5 http://www.opensymphony.org/ Required to build Webwork i18nadapter. Required at runtime only if you use Webwork (if you wish touse it you should already have Webwork in your project)...........................................................................................................................................................................................xwork jar 1.0.3 http://www.opensymphony.org/ Required to build Webwork i18nadapter. Required at runtime only if you use Webwork (if you wish touse it you should already have Webwork in your project)...........................................................................................................................................................................................oscore jar 2.2.4 http://www.opensymphony.org/ Required to build Webwork i18nadapter. Required at runtime only if you use Webwork (if you wish touse it you should already have Webwork in your project)...........................................................................................................................................................................................ognl jar 2.6.5 http://www.ognl.org/ Required to build Webwork i18n adapter.Required at runtime only if you use Webwork (if you wish to use it youshould already have Webwork in your project)1 . 2 D E P E N D E N C I E S3 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.1Download......................................................................................................................................Downloadreleases\ou can download source and binary distributions rom the Sourcelorge Serer .development snapshot1he latest snapshot build ,usually uploaded in sync with this website, can be downloaded directly romhere . Get this one only i you are a deeloper or you absolutely need a eature,ix added beore the latestrelease ,see changes or the ull change log,.source code from CVS\ou can also obtain the source rom the Sourcelorge CVS Serer, see Source Repository .Files1he "bin" ersions include the ollowing: displaytag.jar - the jar ile that contains the taglib classes, you need to drop this ile into your webapplication \LB-INl,lib directory. displaytag.tld - the tld ile that contains the tag library descriptor, you need to drop this ile into yourweb application \LB-INl directory. displaytag.war - the documentation and the example applications that appear on this web site,optionally drop this into your web container deployment directory.1he "src" ersions includes the complete source code to the tag library, the arious example pages, andthe documentation.2 . 1 D O W N L O A D4 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.2Install......................................................................................................................................Installation Guide1his package comes with pre-built binaries located in the dist directory. 1hose distribution iles are:file descriptiondisplaytag.war documentation and examples...........................................................................................................................................................................................displaytag.jar the taglib jar...........................................................................................................................................................................................displaytag.tld the taglib tld file1o quickly iew the documentation and examples showing the eatures and unctionality o the displaytaglib, just deploy the displaytag.war ile to your application serer ,the details o how dier rom sererto serer, or serlet container.I you would like to make use o the display taglib in your own application, do the ollowing:STEP 1 : Drop the displaytag-ersion}.jar ile in your applicationWEB-INF/lib directorySTEP 2 : Make sure that ollowing libraries are in your WEB-INF/lib directory ,or made aailable ia theclasspath to your application serer,. Reer to the dependencies document or the correct ersion o theselibraries. \ou can download a copy o eerything rom jakarta or you can grab them rom the examplewebapp in the bin distribution. commons-logging.jar commons-lang.jar commons-collections.jar commons-beanutils.jar log4j.jarSTEP 3 : ^eeaea ovt, for ]P 1.1 covtaiver. . Drop the displaytag-taglibersion}.tld ile in your applicationWEB-INF/ directory. Reer to the tlds page or the aailable tlds.STEP 4 : ^eeaea ovt, for ]P 1.1 covtaiver.. Deine a taglib element like the ollowing in your,\LB-INl,web.xml ile

http://displaytag.sf.net/WEB-INF/displaytag-{taglibversion}.tld

2 . 2 I N S T A L L5 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DSTEP 5 : Otiovat. Depending on your architecture, you may need to conigure a ilter to make exportwork. See the export ilter page or the details about how to do it and when you could need it.DONE : Deine the tag extension in each JSP page that uses the display taglib. 1he uri directies mustmatch what you deined in the web.xml ile aboe OR the URI deined in one o the tlds in the jar ile.\ith JSP 1.2 containers, the jar ile is automatically scanned and you don't need to deine an entry in yourweb.xml ile. 1he preix identiies the tags in the tag library within the JSP page.

1he declaration, i you are using a JSP XML syntax, looks like:

lor more help with general taglib use, please see: http:,,jakarta.apache.org,taglibs,tutorial.html2 . 2 I N S T A L L6 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.3Tlds......................................................................................................................................TldsDisplaytag comes with 3 dierent tlds at the moment. Look at this table to understand which is the rightone or you.tld URI descriptiondisplaytag-11.tld http://displaytag.sf.net Jsp 1.1 version of the tld, you will need to usethis one if you plan to install your applicationon container only supporting j2ee 1.2 (Tomcat3, Websphere 4, WebLogic 6...)............................................................................................................................................................................................displaytag-12.tld http://displaytag.sf.net Jsp 1.2 version of the tld: requires j2ee 1.3(Tomcat 4, WebSphere 5, WebLogic 7...).Use this version if you are not looking for j2ee1.2 compatibility and don't need EL support............................................................................................................................................................................................displaytag-el-12.tld http://displaytag.sf.net/el EL version of the tag library. It offers thesame features as the standard 1.2 version,plus Expression Language Support. It willrequire a couple of addictional libraries, seethe dependencies page. Don't use this oneif you are looking for EL support on jsp 2.0containers (Tomcat 5). In Jsp 2.0compatible servers expressions are evaluateddirectly by the container, so you can use thestandard 1.2 tld and still have EL support (theEL tld will not work, since expressions wil beevaluated twice).2 . 3 T L D S7 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.4Tag reference......................................................................................................................................Display *: Tag Library1he display tag library is an open source suite o custom tags that proide high leel web presentationpatterns which will work in a MVC model, and proide a signiicant amount o unctionality while stillbeing simple and straight-orward to use. 1he primary tag in the library is the 1able tag. 1his is ersion1.0 . caption Simple tag which mimics the html caption tag . column Displays a property o a row object inside a table . ooter 1ag wich should be nested into a table tag to proide a custom table ooter . setProperty Sets the indicated property on the enclosing 1able tag . table Displays a list in an html table, ormatting each item in the list according to the Column tagsnested inside o this tag .Reqvirea attribvte. are var/ea ritb a .tableDisplays a list in an html table, ormatting each item in the list according to the Column tags nested insideo this tag. Use the list attribute to indicate the Collection o data, in some scope, that the tag shouldoperate on. Supports the export o the list data to alternatie ormats such as CSV, Lxcel, and XML. 1hecontents o the list can be sorted, and the list can be broken into indiidual pages or display. I you usethis tag in Struts, or in some other ramework where the page is included ia a jsp:include, you should usethe requestURI attribute to indicate where tag generated links should point.Can contain: JSPExample

2 . 4 T A G R E F E R E N C E8 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DAttributesName Description Typecellpadding html pass through attribute. Better using"padding" css attribute in style or classString...........................................................................................................................................................................................cellspacing html pass through attribute String...........................................................................................................................................................................................class html pass through attribute String...........................................................................................................................................................................................decorator Fully qualified class name for aTableDecorator. Use a TableDecorator toprovide custom operations against the wholelist, such as computing totals. Must extendorg.displaytag.decorator.TableDecorator.String...........................................................................................................................................................................................defaultorder The default order for the sorted column. Validvalues are "ascending" (default) or"descending"String...........................................................................................................................................................................................defaultsort The index of the column that will be used bydefault for sorting (starting from 1)int...........................................................................................................................................................................................excludedParams Whitespace separated list containg the nameof parameters which should NOT beforwarded during paging or sorting. You canuse excludedParams="*" to match (exclude)any parameter.String...........................................................................................................................................................................................export enable/disable export. Valid values are true orfalseboolean...........................................................................................................................................................................................frame html pass through attribute. String...........................................................................................................................................................................................htmlId html "id" pass through attribute String...........................................................................................................................................................................................id See "uid". The id attribute can't be a runtimeexpression in jsp 1.0 compliant containers,while uid will allow it.String...........................................................................................................................................................................................length number of records to be shown int...........................................................................................................................................................................................list Reference to the object used as source forthe table. Can be an expression likerequestScope.object.property . You mustdefine either the name attribute or the listattribute. Using "Name" is suggested.String...........................................................................................................................................................................................name reference to the object used as source for thetable. Can be an expression likerequestScope.object.property. In the ELversion of the taglibrary this must be an ELexpression which points to the source object.String...........................................................................................................................................................................................offset index of the first record to be shown int...........................................................................................................................................................................................pagesize number of records in a page int...........................................................................................................................................................................................requestURI When the present, links for sorting, exports,and paging are formed by adding any taggenerated parameters to the value ofrequestURI attribute.String...........................................................................................................................................................................................requestURIcontext Enable/disable prepending of applicationcontext to generated links. Default is true, youcan set it to false in order to generatecross-context links.boolean...........................................................................................................................................................................................2 . 4 T A G R E F E R E N C E9 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DName Description Typerules html pass through attribute. String...........................................................................................................................................................................................sort Use 'page' if you want to sort only visiblerecords, or 'list' if you want to sort the full listString...........................................................................................................................................................................................style html pass through attribute String...........................................................................................................................................................................................summary html pass through attribute String...........................................................................................................................................................................................uid Unique id used to identify this table. Theobject representing the current row is alsoadded to the pageContext under this nameand the current row number is added usingthe key uid_rowNum. Two tables in the samepage can't have the same uid (paging andsorting will affect both). If no "htmlId" isspecified the same value will be used for thehtml id of the generated table.String...........................................................................................................................................................................................styleClass @deprecated: use "class" String...........................................................................................................................................................................................align @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................background @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................bgcolor @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................height @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................hspace @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................vspace @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................width @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................border @deprecated html pass through attribute.Use css "border"String...........................................................................................................................................................................................scope @deprecated in displaytag 1.0. Use"pageScope.", "requestScope.","sessionScope.", "applicationScope." prefixesin name. Not supported in the EL version ofthe tag.String...........................................................................................................................................................................................property @deprecated in displaytag 1.0. Uselist.property in "name" attribute. Notsupported in the EL version of the tag.StringcolumnDisplays a property o a row object inside a table. MUS1 be nested inside o a 1able tag. 1he aluedisplayed will be the results o a decorator ,i any,, else the property named by the 'property' attribute, or2 . 4 T A G R E F E R E N C E10 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Di the 'property' attribute is null, then the results o ealuating the JSP body o the tag.Can contain: JSPAttributesName Description Typeautolink Automatically hyperlink URLs and emailaddresses that appear in the column.Defaults to 'false'.boolean...........................................................................................................................................................................................class html pass through attribute; use this insteadof directly coding presentational atttributes.String...........................................................................................................................................................................................decorator The fully qualified class name of a class thatshould be used to "decorate" the underlyingobject being displayed. The class shouldimplementorg.displaytag.decorator.ColumnDecorator. Ifa decorator is specified for the entire table,then this decorator will decorate thatdecorator.String...........................................................................................................................................................................................group The grouping level (starting at 1 andincrementing) of this column (indicates ifsuccessive contain the same values, thenthey should not be displayed). The levelindicates that if a lower level no longermatches, then the matching for this higherlevel should start over as well. If this attributeis not included, then no grouping isperformed.int...........................................................................................................................................................................................headerClass "class" html attribute added only for headercells.String...........................................................................................................................................................................................href The base URL used to construct the dynamiclink. If this attribute is provided, then the datathat is shown for this column is wrappedinside a tag with the url providedthrough this attribute. Typically you would usethis attribute along with one of the struts-likeparam attributes (param*) to create adynamic link so that each row creates adifferent URL based on the data that is beingviewed. An empty href value will generate alink to the current page, preservingparameters just like for paging links.String...........................................................................................................................................................................................maxLength If this attribute is provided, then the column'sdisplayed is limited to this number ofcharacters. An elipse (...) is appended to theend if this column is linked, and the user canmouseover the elipse to get the full text. Becareful on using this attribute for String whichcan contain html tags or entities, or togetherwith the autolink attribute turned on:displaytag will do its best trying to avoidleaving unclosed tags or broken entities in theoutput, but a complex or bad input could leadto unattended results.int...........................................................................................................................................................................................2 . 4 T A G R E F E R E N C E11 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DName Description TypemaxWords If this attribute is provided, then the column'sdisplayed is limited to this number of words.An elipse (...) is appended to the end if thiscolumn is linked, and the user can mouseoverthe elipse to get the full text. Be careful onusing this attribute for String which cancontain html tags or entities, or together withthe autolink attribute turned on: displaytag willdo its best trying to avoid leaving unclosedtags or broken entities in the output, but acomplex or bad input could lead tounattended results.int...........................................................................................................................................................................................media Use this attribute to keep a column frombeing output during an export. The columnwill only render for the named media type(s) -it won't be added to the table if the currentrequest media is not supported. Can be anyspace separated combination of 'html', 'csv','xml', 'all', or 'excel'. Defaults to 'all'. See theexport page in the example webapp for moredetails.String...........................................................................................................................................................................................nulls By default, null values don't appear in the list.By setting 'nulls' to 'true', then null values willappear as "null" in the list (mostly useful fordebugging). Defaults to 'false'.boolean...........................................................................................................................................................................................paramId The name of the request parameter that willbe dynamically added to the generated hrefURL. The corresponding value is defined bythe paramProperty and (optional)paramName attributes, optionally scoped bythe paramScope attribute.String...........................................................................................................................................................................................paramName The name of a JSP bean that is a Stringcontaining the value for the requestparameter named by paramId (ifparamProperty is not specified), or a JSPbean whose property getter is called to returna String (if paramProperty is specified). TheJSP bean is constrained to the bean scopespecified by the paramScope property, if it isspecified. If paramName is omitted, then it isassumed that the current object being iteratedon is the target bean.String...........................................................................................................................................................................................paramProperty The name of a property of the current objectbeing iterated on, whose return value will beused as the value of the parameter (namedby the paramId attribute) that will bedynamically added to this href URL. IfparamName is also specified the property willnot be fetched from the object being iteratedon, but from the bean specified byparamName. The support of paramPropertyin conjunction with paramName will beprobably removed in future: useparamProperty only if you need a property inthe iterated object, elsewhere use onlyparamName (you can select a property usingan expression name.property).String...........................................................................................................................................................................................property name of the property in the bean specified inthe parent table tag (via the "name" attribute)mapped to this columnString...........................................................................................................................................................................................sortable Set to 'true' to make the column sortable.Defaults to 'false'.boolean...........................................................................................................................................................................................2 . 4 T A G R E F E R E N C E12 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DName Description TypesortProperty name of the property in the bean specified inthe parent table tag (via the "name" attribute)which will be used to sort values in thecolumn. This can be used when the columnbody is filled or a decorator is used andcolumn should sort on undeorated values.String...........................................................................................................................................................................................style html pass through attribute. String...........................................................................................................................................................................................title title of the column (text for the th cell) String...........................................................................................................................................................................................titleKey Resource key used to lookup the title value.Only works if "title" is not defined. Workstogether with a configuredI18nResourceProvider, specified via thedisplaytag.properties file. By default, if JSTLis available, the JSTL provider is used, whichmakes this attribute work the same asfmt:message's key property.String...........................................................................................................................................................................................url The base URL used to construct the dynamiclink. This attribute has the same functionalityas the href attribute, but it pre-pends thecontextPath.String...........................................................................................................................................................................................width @deprecated; html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................styleClass @deprecated: use "class" String...........................................................................................................................................................................................headerStyleClass @deprecated: use "headerClass" String...........................................................................................................................................................................................sort @deprecated: use "sortable" boolean...........................................................................................................................................................................................align @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................background @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................bgcolor @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................height @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................nowrap @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................valign @deprecated html attribute. Use "style" or"class" to set presentational attributes usingcss.String...........................................................................................................................................................................................paramScope @deprecated - use Expressions inparamName. The scope within which tosearch for the bean specified by theparamName attribute. If not specified, allscopes are searched. If paramName is notprovided, then the current object beingiterated on is assumed to be the target bean.String2 . 4 T A G R E F E R E N C E13 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DsetPropertySets the indicated property on the enclosing 1able tag. MUS1 be nested within a 1able tag. As analternatie, you may create a property ile that holds sitewide deaults, see the conigurationdocumentation or the DisplayPropertiesLoaderSerlet jaadoc or inormation.Can contain: JSPExample

orbottomAttributesName Description Type*name The name of the property to set on theenclosing Table tag.String...........................................................................................................................................................................................value The value to which the property is set. Youcan also set the property value in the tagbody.Stringfooter1ag wich should be nested into a table tag to proide a custom table ooter. 1he body o the tag isoutputted as is in the generated table in the toot section.Can contain: JSPExample

total:

2 . 4 T A G R E F E R E N C E14 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D

AttributescaptionSimple tag which mimics the html caption tag. Use it inside a table tag to display a caption.Can contain: JSPExample

This is the table caption

AttributesName Description Typeclass html pass through attribute. String...........................................................................................................................................................................................dir html pass through attribute. String...........................................................................................................................................................................................id html pass through attribute. String...........................................................................................................................................................................................lang html pass through attribute. String...........................................................................................................................................................................................style html pass through attribute. String...........................................................................................................................................................................................title html pass through attribute. String2 . 4 T A G R E F E R E N C E15 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.5Configuration......................................................................................................................................Configuration properties1his table lists all the conigurable properties or the tag libraries. 1he deault properties are deined inthe TableTag.properties ile included in the library jar.1here are 2 ways to oerride deault property settings: lor the whole web application, create a custom properties ile named "displaytag.properties" andplace it in the application classpath. Displaytag will use the locale o the request object to determinethe locale o the property ile to use, i the key required does not exist in the speciied ile, the key willbe loaded rom a more general property ile. lor a single table instance, using the display:setProperty tagInclude in your custom properties ile only the properties you need to change. I a property is not deinedin the user ile, the deault rom the 1able1ag.properties included in the jar is used.I18nSome properties contain messages you may wish to display according to the user Locale. 1o do that irstadd a deault displaytag.properties ile where you set all the locale independent entries anddeault messages. 1hen you can add localized properties ile ,or exampledisplaytag_IT.properties ,.GenericProperty Default Valid Values DescriptionCan be set usingfile/setPropertybasic.show.header true true, false Indicates if you want theheader to appear at thetop of the table, theheader contains thecolumn names, and anyadditional action bannersthat might be required(like paging, export, etc...)yes/yes...........................................................................................................................................................................................basic.empty.showtable false true, false Indicates if you want thetable to show up also ifthe list is emptyyes/yes...........................................................................................................................................................................................2 . 5 C O N F I G U R A T I O N16 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DProperty Default Valid Values DescriptionCan be set usingfile/setPropertybasic.msg.empty_list Nothing found to display Any string The message that isdisplayed if the list thatthis table is associatedwith is either null, orempty. Used only ifbasic.empty.showtableis false .yes/yes...........................................................................................................................................................................................basic.msg.empty_list_row Nothingfound to display.

Any string The message that isdisplayed into the firsttable row if the list that thistable is associated with iseither null, or empty. {0} isreplaced with the totalcolumn number togenerate a correctcolspan. Used only ifbasic.empty.showtableis true .yes/yes...........................................................................................................................................................................................sort.amount page page, list Indicates if the full listshould be sorted beforepaging or if the sortingonly affects items in thecurrent page. Defaultbehaviour is to sort onlyitems in the current page(first paging, then sorting).yes/no...........................................................................................................................................................................................export.banner Export options: {0} Any string in a messageformat with 1 placeholderContains the string that isdisplayed in the tablefooter when the userindicates that they want toenable the export function.The placeholder isreplaced with links to thevarious export formatsthat are support.yes/yes...........................................................................................................................................................................................export.banner.sepchar | Any string Used to separate the validexport type (typicallywould be a bar, a comma,or a dash).yes/yes...........................................................................................................................................................................................paging.banner.placement top top, bottom, both When the table tag has toshow the header forpaging through a long list,this option indicates wherethat header should beshown in relation to thetableyes/yes...........................................................................................................................................................................................paging.banner.item_name item Any string What the various objectsin the list being displayedshould be referred to as(singular)yes/yes...........................................................................................................................................................................................paging.banner.items_name items Any string What the various objectsin the list being displayedshould be referred to as(plural)yes/yes...........................................................................................................................................................................................paging.banner.no_items_found No{0} found. Any string in a messageformat with 1 placeholderWhat is shown in thepagination header whenno objects are available inthe list to be displayed.The single placeholder isreplaced with the name ofthe items in the list (plural)yes/yes...........................................................................................................................................................................................2 . 5 C O N F I G U R A T I O N17 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DProperty Default Valid Values DescriptionCan be set usingfile/setPropertypaging.banner.one_item_found One{0} found. Any string in a messageformat with 1 placeholderWhat is shown in thepagination header whenone object is available inthe list to be displayed.The single placeholder isreplaced with the name ofthe items in the list(singular)yes/yes...........................................................................................................................................................................................paging.banner.all_items_found {0}{1} found, displaying all{2}. Any string in a messageformat with 3 placeholdersWhat is shown in thepagination header whenall the objects in the listare being shown. {0} and{2} are replaced with thenumber of objects in thelist, {1} is replaced withthe name of the items{plural}yes/yes...........................................................................................................................................................................................paging.banner.some_items_found {0}{1} found, displaying {2} to{3}. Any string What is shown in thepagination header when apartial list of the objects inthe list are being shown.Parameters: {0}: total number ofobjects in the list {1}: name of the items(plural) {2}: start index of theobjects being shown {3}: end index of theobjects being shown {4}: current page {5}: total number ofpagesyes/yes...........................................................................................................................................................................................paging.banner.group_size 8 Any reasonable number The number of pages toshow in the header thatthis person can instantlyjump toyes/yes...........................................................................................................................................................................................paging.banner.full [First/Prev]{0} [ Next/ Last]What is shown in thepagination bar when thereare more pages and theselected page is not thefirst or the last one.Parameters: {0}: numbered pageslist {1}: link to the firstpage {2}: link to the previouspage {3}: link to the nextpage {4}: link to the lastpage {5}: current page {6}: total number ofpagesyes/yes...........................................................................................................................................................................................paging.banner.first [First/Prev] {0} [ Next/ Last]

What is shown in thepagination bar when thefirst page is being shown.Placeholders are thesame as forpaging.banner.full .yes/yes...........................................................................................................................................................................................2 . 5 C O N F I G U R A T I O N18 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DProperty Default Valid Values DescriptionCan be set usingfile/setPropertypaging.banner.last [First/Prev]{0} [Next/Last] What is shown in thepagination bar when thelast page is being shown.Placeholders are thesame as forpaging.banner.full .yes/yes...........................................................................................................................................................................................paging.banner.onepage {0}What is shown in thepagination bar when onlyone page is returned.Placeholders are thesame as forpaging.banner.full .yes/yes...........................................................................................................................................................................................paging.banner.page.selected{0} selected page. {0} isreplaced with the pagenumber, {1} with the pageurl.yes/yes...........................................................................................................................................................................................paging.banner. page.link {0}link to a page. {0} isreplaced with the pagenumber, {1} with the pageurl.yes/yes...........................................................................................................................................................................................paging.banner.page.separator , separator between pages yes/yes...........................................................................................................................................................................................factory.requestHelper org.displaytag.util.DefaultRequestHelperFactory Class name for a validRequestHelperFactoryimplementationRequestHelperFactory tobe used. You can replacethe default one if youneed to generate linkswith a different format (forexample in portalapplications).yes/noExportingDisplaytag supports exporting to excel, cs, and xml ormats. Some conigurable properties are speciicor one o these ormat. Replace " eort vave " in the property name with "excel", "cs" or "xml".Some o the properties won't work in any export ormat.Property Default Valid Values DescriptionCan be set usingfile/setPropertyexport.types csv excel xml pdf whitespace separated listof configured export typesHolds the list of configuredexport types.yes/no...........................................................................................................................................................................................export. {export name} true true, false Should the tag present theoption to export data inthis specific format.yes/yes...........................................................................................................................................................................................export. {exportname}.classAny valid class whichimplements theorg.displaytag.export.ExportViewinterfaceFully qualified class namefor the class which will beused for exporting.yes/no...........................................................................................................................................................................................export. {exportname}.label {exportname} Any string The label on the link thatthe user clicks on toexport the data in aspecific format.yes/yes...........................................................................................................................................................................................2 . 5 C O N F I G U R A T I O N19 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DProperty Default Valid Values DescriptionCan be set usingfile/setPropertyexport. {exportname}.include_headerfalse true, false If set to true, the first lineof the export will containcolumn titles as displayedon the HTML page. Theheader by default is notincluded in whenexporting.yes/yes...........................................................................................................................................................................................export. {exportname}.filenamenone any valid file name When saving exportedfiles the user will beprompted to use this filename.yes/yes...........................................................................................................................................................................................export.amount list page, list Indicates how much datashould be sent down tothe user when they ask fora data export. By default,it sends the entire list. But,you can instruct the tabletag to only send down thedata that is currently beingshown on the pageyes/yes...........................................................................................................................................................................................export.decorated true true, false Should the data be"decorated" as it isexported. The defaultvalue is true, but youmight want to turn off anydecoration that is forexample HTML specificwhen exporting the data.yes/yescssProperty Default Valid Values DescriptionCan be set usingfile/setPropertycss.tr.even even any valid css class name css class automaticallyadded to even rowsyes/yes...........................................................................................................................................................................................css.tr.odd odd any valid css class name css class automaticallyadded to odd rowsyes/yes...........................................................................................................................................................................................css.th.sorted sorted any valid css class name css class automaticallyadded to the header ofsorted columnsyes/yes...........................................................................................................................................................................................css.th.ascending order1 any valid css class name css class automaticallyadded to the header of acolumn sorted isascending orderyes/yes...........................................................................................................................................................................................css.th.descending order2 any valid css class name css class automaticallyadded to the header of acolumn sorted isdescending orderyes/yes...........................................................................................................................................................................................css.table none any valid css class name css class automaticallyadded to the main tabletagyes/yes...........................................................................................................................................................................................css.th.sortable none any valid css class name css class automaticallyadded to any sortablecolumnyes/yes2 . 5 C O N F I G U R A T I O N20 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.5 CONFIGURATION21 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D2.6Export filter......................................................................................................................................Export filter? What's that?\hen displaytag exports data in any non-html ormat, it needs to change the content type returned to thebrowser and reset any other content generated by the surrounding page.Sometimes this can't be done: i content has already been sent back to the user, the response can't bereset and you get an error. 1his could happen because: 1oo many chars hae been already written to the response, so that the response buer was ull andresponse has been automatically lushed. Something ,tags jaa snippets, beore the display:table tag has explicitely lushed the response, response.flushBuffer() ,. \our page is dinamically included into another page. 1his happens or example using Struts tiles.Another problem is related to exporting binary iles. 1he output o binary data is not supported in jsps: itmay work on some application serer, but it may end up with errors in others. Because o this restrictionan "external help" may be required. Cs, xml and excel ormats don't require a binary output, but i youwant to try a pd export or other custom binary ormats you will hae to ace some problems.The solution1he irst attempt can be using a larger page buer in your jsp pages, or example:

loweer, this can work only i you are in the irst situation listed aboe.In j2ee 1.3,jsp 1.2 containers you can take adantage o ilters to sole the problem. Displaytag shipswith a ilter which works together with the table tag during export, disallowing the response to be lushedwhen an export has been requested.Installing the export filterConigure the lilter in your web.xml:

ResponseOverrideFilterorg.displaytag.filter.ResponseOverrideFilter

2 . 6 E X P O R T F I L T E R22 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DAnd add mappings or the pages that you will intercept, or example:

ResponseOverrideFilter*.do

ResponseOverrideFilter*.jsp

2 . 6 E X P O R T F I L T E R23 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.1Basic usage......................................................................................................................................Simplest case, no columns

1he simplest possible usage o the table tag is to point the table tag at a jaa.util.List implementation anddo nothing else. 1he table tag will iterate through the list and display a column or each propertycontained in the objects.1ypically, the only time that you would want to use the tag in this simple way would be duringdeelopment as a sanity check. lor production, you should always deine at least a single column.Basic, columns

3 . 1 B A S I C U S A G E24 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D1his example starts to show you how to use the table tag. \ou point the table tag at a datasource ,a List,,then deine a number o columns with properties that map to accessor methods ,getXXX, or eachobject in the List.Note that you hae one column tag or eery column that you want to appear in the table. And, thecolumn speciies what property is shown in that particular row.\ou can deine the content o a column by adding a property attribute to the column tag or adding acontent to the tag. display:column property~"email" , display:column title~"email"emailit.com,display:column1here are two ways to deine the content o a column. O course, in the tag body you can use scriptletsor other custom tags. Using the property attribute to deine the content o a column is usually asterand works better with sorting. I you add a property attribute the tag body is ignored.Adding content in the column body you can easily concatenate or "decorate" ields aailable in objects inthe list. See the implicit objects chapter or more details.1he property attribute speciies what getXXX method is called on each item in the list. So or thesecond column, getName is called. By deault the property name is used as the header o the columnunless you explicitly gie the column a title.3 . 1 B A S I C U S A G E25 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.2Implicit objects......................................................................................................................................Implicit objects created by table

static

I you add and id attribute the table tag makes the object corresponding to the gien row aailable in thepage context so you could use it inside scriptlet code or some other tag. Another implicit object exposedby the table tag is the row number, named id_rowNum .1hese objects are saed as attributes in the page scope ,you can access it usingpageContext.getAttribute("id") ,. 1hey are also deined as nested ariables ,accessible using ,, but only i the alue o the id atribute is not a runtime expression. 1he preerred way oretching the alue is to always use pageContext.getAttribute,,.I you do not speciy the id attribute no object is added to the pageContext by the table tag1his is a simple snippet which shows the use o the implicit objects created by the table tag with JS1L.

3 . 2 I M P L I C I T O B J E C T S26 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.3Data sources......................................................................................................................................Data sourcesExpressionsUp until this point, we hae simply had a List object aailable to us under the name "list" in the requestscope that has drien the display o the tables shown. \e hae been setting up that bean with theollowing scriptlet, but presumably you would be doing something similar in your Action class rather thenraw on this jsp page.

1his table is called with the ollowing attributes:

\ou can also acquire a handle to the list you want to display by speciying not only a bean name, but alsoa bean property ,a getter method,, and the table tag will call that property to etch the list to display.Actually there are two "laors" o displaytag: an LL ersion, which requires j2ee 1.3 and a jsp 1.1 ,j2ee1.2 compatible, ersionIn the LL ersion you can obiously use an LL expression, like name~">pageScope.name.property}"In the non-LL ersion you can deine the "name" attribute using a really similar sintax, just without the${}:\ou can deine the scope o the bean adding one o the ollowing suix: pageScope requestScope ,deault, sessionScope applicationScope\ou can also access jaabean style properties, mapped properties or indexed properties in the bean, alsonested. 1he syntax or accessing a jaabean property is .property . \ou can read a mapped propertyspeciying it between () and an indexed property using [].So the ollowing:sessionScope.list.value.attribute(name).item[1]3 . 3 D A T A S O U R C E S27 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Dis equialent to:session.getAttribute("list").getValue().getAttribute("name").getItem(1)Supported data1he table tag actually supports the ollowing kind o objects: a Collection an Lnumeration a Map ,alues are displayed in row, a Dictionary ,alues are displayed in row, an array an Iterator any Object with an iterator,, method ... any other object will be displayed on a single rowFrom a db?Displaytag will never support retrieving data from a db directly. Displaytag is here to help you indisplaying data, not to retriee them.Anyway, there are a couple o easy methods to get records rom a db and display them using displaytag:1, Using jstl:just use the sql:query tag and pass the result to the table tag in this way

select * from table

(or

if not using the EL version)2, Using dynabeansseehttp:,,jakarta.apache.org,commons,beanutils,api,org,apache,commons,beanutils,RowSetDynaClass.html

3 . 3 D A T A S O U R C E S29 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.4Decorators......................................................................................................................................DecoratorsA "decorator" is a design pattern where one object proides a layer o unctionality by wrapping or"decorating" another object.Table decorators

Let's assume you hae list o business objects that you want to display, and the objects contain propertiesthat don't return natie Strings, and you want control oer how they get displayed in the list ,or example,Dates, money, numbers, etc...,. I would be bad orm to put this type o ormatting code inside yourbusiness objects, so instead create a Decorator that ormats the data according to your needs.Notice the ollowing 4 key things ,and reer to the 1ableDecorator jaadoc or some o the other details,. 1he \rapper class must be a subclass o 1ableDecorator. 1here is arious bootstrapping and APImethods that are called inside the 1ableDecorator class and your class must subclass it or things towork properly ,you will get a JspLxception i your class does not subclass it,. Be smart and create your ormatters just once in the constructor method - perormance will be a lotbetter... Notice how the getDate,, and getMoney,, methods oerload the return alue o your business objectcontained in the List. 1hey use the TableDecorator.getCurrentRowObject() method to geta handle to the underlying business object, and then ormat it accordingly. \e do not hae to oerload each o the other business object properties ,like getID, getLmail, etc...,.1he decorator class is called irst, but i it doesn't implement the method or the property called, thenthe underlying business class is called.1he way this works is that a single decorator object is created right beore the table tag starts iteratingthrough your List, beore it starts processing a particular row, it gies the object or that row to thedecorator, then as the arious properties getXXX,, methods - the decorator will be called irst and i the3 . 4 D E C O R A T O R S30 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Ddecorator doesn't implement the gien property, the method will be called on the original object in yourList.Column Decorators\ou can also speciy decorators that work on indiidual columns, this would allow you to come up withdata speciic ormatters, and just reuse them rather then coming up with a custom decorator or eachtable that you want to show a ormatted date or.

Table decorators, column decorators or code in the column body?As a rule o thumb, a decorator is aster than using scriptlet or custom tags in the column body whenusing paging. \hen the column body is illed and ull list is sorted, all the records need to be "prepared"by the table tag iterating on the whole list. I the column body is used the content will be ealuated orany row, also or the non displayed ones, using property , on the other hand, will cause the decoratoronly to be called or displayed rows.A table decorator hae the power to add extra properties to your objects: or example you can add agetFullAddress() method to your table decorator and then use property="fullAddress" in acolumn. A table decorator can also proide custom html code added at the beginning,end o rowss andtable.A column decorator is rather limited in its uncionality: it simply ormat an aailable alue, and hasactually no access to the page context or other properties. loweer, it is the simplest and most reusableblock i you simply need to ormat dates, number or custom strings.Leaing decorators out and illing the column body is the simplest solution i you don't hae to worry toomuch about paging and perormance and it is optimal in a small, non paged, table. During sorting,though, i the column body is used, the result will be always sorted as a String.3 . 4 D E C O R A T O R S31 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.5Links......................................................................................................................................Generating linksSmart linking of column dataI you hae email addresses or web URLs in the data that you are displaying in columns o your table,then you can set the autolink="true" attribute in your display:column tag, and that will tell thedisplay:table to automatically display those pieces o data as hyperlinks, you will not hae to take anyaction to conert that data. Lmail addresses will be wrapped with a xxx tag, where "xxx" isthe email address that was detected. \eb URLs will be wrapped with a xxx tag, where "xxx" is the URL thatwas detected ,it can be any alid URL type, http:,,, https:,,, tp:,,, etc...,I your column data has additional text, only the data that appears to be an email address or a URL will belinked ,not the entire column,.1urning on autolink does carry a perormance penalty, as each string has to be scanned or patterns andupdated i it matches on an address or URL.Dynamic links1here are two ways to create dynamic links that should appear in a column. 1he irst method is a"struts-like" approach which works well i the link you want to create is based on just a single property othe object being displayed ,like a primary key alue,. 1he second approach makes use o decorators asdescribed on the preious example. A decorator should be used when the dynamic link being createdrelies on multiple pieces o inormation, relies on the index o the object in the list, relies on some otherdata around it, or you want to change the text that is linked ,ie you want it to say "edit", instead oshowing the primary key o the object,. Below I show how to use both examples.Struts-like approach1he column tag proides 5 struts-like attributes that can be set to create a dynamic linke , hre, paramID,paramName, paramProperty, paramScope ,. See the display:column documentation, and the strutsdocumentation or a complete description o their usage, but basically:hrethe base URL used to construct the dynamic linkparamId3 . 5 L I N K S32 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Dthe name o the parameter that gets added to the URL speciied aboeparamNamename o the bean that contains the data we want to tack on the the URL ,typically null, indicatingthe current object in the List,paramPropertyproperty to call on the object speciied aboe to return the alue that gets tacked onto the URL.paramScopespeciic scope where the databean lies, typically nullO these params, you typically would not use paramName and paramScope. Leaing each as nullindicates that you want to use the object corresponding to the current row being processed.

Using a decorator1he preious example page introduced the decorator to ormat dates, money, etc... It can also be used tocreate dynamic links on the ly so that you can either click on a particular column alue and "drill down"or more inormation, or you can create a column o text labels which are hyperlinks that perorm someaction on the object in that row.1hese dynamic links can be created based on some primary key o the object, or they can make use o theobject List index.Below is a table that has two columns that hae hyperlinks created on the ly, the irst makes use o theobject's "ID" ield to show additional details about that object, while the second makes use o the object'srow index alue to do basically the same thing.lere you can see the details o the getLink1,, and getLink2,, methods in the sample 1ableDecoratorpublic String getLink1(){ListObject lObject= (ListObject)getCurrentRowObject();int lIndex= getListIndex();return "" +lObject.getId() + "";}3 . 5 L I N K S33 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Dpublic String getLink2(){ListObject lObject= (ListObject)getCurrentRowObject();int lId= lObject.getId();return "View | "+ "Edit | "+ "Delete";}

3 . 5 L I N K S34 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.6Style......................................................................................................................................Style\ou actually hae a lot o lexibility in how the table is displayed, but o course you should probably stayclose to the deaults in most cases. \ou adjust the look o the table ia two methods:1. pass through table and column attributes2. style sheetsHtml attributes\ou can assign to the display:table tag any standard html strict attribute ,es. style, class, cellspacing,cellpadding,, and it will be included in the rendered table.Likewise, you can assign to the display:column tag any standard html attribute and it will be includedin any td tag o the rendered table. \ou can also speciy a class to be used only or the column header,th, using the headerClass attribute.ltml transitional attributes are also supported in ersion 1.0 but they will be remoed soon, so you areencoraged to aoid any html presentational attribute ,such as border, background, bgcolor, width,height...,: there are replaced by an appropriate use o css rules. See the tag reerence page or the ull listo supported, deprecated attributes.Style Sheets1he display:table tag produces well ormed html tables with thead and tbody sections. Cssclasses are also automatically added to rows,cells when needed.\ou can easily customize the generated table simply speciing appropriate css rules in your stylesheet,based on these classes,selectors.All the automatically added css classes can be customized in displaytag.properties. \ou can also add a cssclass to any generated display:table i needed. 1his is the list o css classes added by deault:class assigned toodd assigned to the tr tag of all odd numbered data rows...........................................................................................................................................................................................even assigned to the tr tag of all even numbered data rows...........................................................................................................................................................................................sorted assigned to the th tag of the sorted column...........................................................................................................................................................................................order1 assigned to the th tag of the sorted column if sort order is ascending...........................................................................................................................................................................................3 . 6 S T Y L E35 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Dclass assigned toorder2 assigned to the th tag of the sorted column if sort order is descending...........................................................................................................................................................................................sortable assigned to the th tag of a sortable column3 . 6 S T Y L E36 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.7Export......................................................................................................................................Exporting data\hen you set the 1able 1ag's export attribute to "true", a ooter will appear below the table which willallow you to export the data being shown in arious ormats.Displaytag includes a ew ready made eort rier. which allow you to export data in CSV, excel, and XMLormat. A simple PDl export iew is also aailable. 1he ollowing table lists the predeined exportoptions included in displaytag distribution.Media Export View Class DescriptionCSV org.displaytag.export.CsvView Export to comma separated list...........................................................................................................................................................................................Excel org.displaytag.export.ExcelView Export to excel - ascii format, tab separated...........................................................................................................................................................................................XML org.displaytag.export.XmlView Simple xml output...........................................................................................................................................................................................PDF org.displaytag.export.PdfView Sample PDF export view. This is not enabledby default in the distribution but can beenabled by setting export.pdf=true indisplaytag.properties and including therequired IText dependency (see displaytagdependencies ). Since you probably want totweak the layout of your pdf output, this isprobably more useful as a base reference forcreating your own PDF export view.Configuring export and export views1he export.types parameter contains the list o registered export iews. lor each export type you canconigure other parameters: see the export. exportname.* parameters in coniguration .\ou can enable,disable a speciic export type using the export. exportname.enabled parameter.I you don't want some column to show during export ,or you only want them to show during export,you can use the column media attribute ,see tag reerence or more details,.Adding a new Export view1. \rite your own exportView class. \ou need to implement theorg.displaytag.export.TextExportView ororg.displaytag.export.BinaryExportView interace. \ou can look at the sample binaryPDl export iew or to the base text export iew used by displaytag .2. Add a displaytag.properties ile in your application classpath ,i you already don't hae one,3 . 7 E X P O R T37 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E Dand add the name o your export media along with the deault ones to the export type parameter:export.types=csv excel xml [mymedia]3. Always in displaytag.properties , add the ollowing properties:export.[mymedia]=trueexport.[mymedia].class=fully.qualified.class.nameexport.[mymedia].label=Click here to try my export# include header parameter is forwarded to your export viewexport.[mymedia].include_header=true# if set, file is downloaded instead of opened in the browser windowexport.[mymedia].filename=4. 1ry it. \ou should see a new link with the text you added to export. mymedia .label .Clicking on it will inoke your Lxport iew. \ou should see the results in your browser.Text/Binary export viewsCommon displaytag export options ,CSV, Xml and Lxcel, output a simple text-based ormat. Other ileormats require binary content, like the sample PDl included with the distribution.Lxporting binary data rom a JSP is a bit tricky, since JSPs are only designed to output characters: as astarting point keep in mind that binary export is not assured to work on every application server , at leastwithout the help o an external ilter ,see export ilter ,.It may work without a ilter i your application serer allows JSPs to callresponse.getOutputStream() , but this method really shouldn't be used in JSPs. Using an theexport ilter, especially in buered mode, could sole the problem, since the output stream is requestedby the ilter outside the JSP.3 . 7 E X P O R T38 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E D3.8I18n......................................................................................................................................i18n - InternationalizationI you use displaytag in a multi-language application, you will probably need to translate html generatedby displaytag as well. Displaytag supports i18n or html snippets used in the paging and export bannerand or the title o column headers.i18n for displaytag resourcesUsing the displaytag.properties ile you can set all the messages handled by displaytag.Coniguring:paging.banner.one_item_found=One item found\ill make displaytag output One item found when only a row is displayed.In order to support other languages you can add any number o additional iles nameddisplaytag_LANGUAGE.properties . lor example, you can add adisplaytag_IT.properties or italian users with the ollowing content:paging.banner.one_item_found=Un solo elemento trovato\ou don't need to copy all the properties in any internationalized ile ,some o them are alsoconiguration properties which don't need to be translated at all,. Conigure displaytag properly in themain displaytag.properties ile and then replicate only the strings you want to translate.i18n for column title1here are a ew dierent ways to deine the content or a column header in the column tag:1. speciying a title attribute: the content o the title attribute will be used as is or the column header2. speciying a titlekKey attribute: the content o the titlekey will be used to lookup a resource in aresource bundle and the alue will be used in the column header. I the speciied key can't be ound3 . 8 I 1 8 N39 2 0 0 2 D I S P L A Y T A G A L L R I G H T S R E S E R V E DAdvancedDisplaytag will probably be used in an application where content is already internationalized using aspeciic ramework, which should proide a way to resole the current locale and to lookup properties ina resource bundle.Displaytag proides a way to plug-in dierent adapters to use the same i18n support you are using in yourapplication.Locale resolutionBy deault displaytag will use the locale speciied in the request ,i.e. the locale set in the user browser,.1his can be ine or a basic use, but you could need a way to oerride this selection and to orce adierent locale.lere comes the problem: i you already use Jstl, Struts or other rameworks you will know that there isno standard way to speciy the locale to use: each ramework works in a dierent way.Displaytag proides an interace LocaleResolver with a ew ready to use implementations whichmatch the behaiour o common rameworks. 1he locale resoler is speciied in thedisplaytag.properties ile using the locale.resolver key.I nothing is speciied the locale rom the request is used, as speciied aboe. loweer, you are ree toconigure here any custom implementation o theorg.displaytag.localization.LocaleResolver interace with a simple methodresolveLocale(HttpServletRequest)Displaytag proides by deault these ready to use implementations:class name behaviourorg.displaytag.localization.I18nJstlAdapter Mimic JSTL, looking for a locale specified in session with theConfig.FMT_LOCALE key............................................................................................................................................................................................org.displaytag.localization.I18nStrutsAdapter Struts adapter, will look for the locale specified byGlobals.LOCALE_KEY...........................................................................................................................................................................................org.displaytag.localization.I18nWebworkAdapter Webwork2 adapter, will look for the locale specified by the fistLocaleProvider action in the stack...........................................................................................................................................................................................org.displaytag.localization.I18nSpringAdapter Spring adapter, will use RequestContextUtils.getLocale() forlocale resolution (which will in turn delegate to the Spring localeresolver)Resources lookupOther than resoling the currently used locale, your ramework will probably proide a standard way tostore i18n resources. Just like or the locale resolution, displaytag wil