View source
30 items found, displaying 1 to 10.
Checkbox Id Name Email Description
39525 Elitr Diam elitr-diam@dolor.com consetetur labore...
82698 At Sea At-sea@accusam.com Stet justo...
79684 Aliquyam Consetetur aliquyam-consetetur@diam.com est clita...
98520 Eirmod Sed eirmod-sed@tempor.com clita takimata...
61766 Nonumy Et nonumy-et@takimata.com et clita...
60231 Nonumy Lorem nonumy-Lorem@tempor.com est consetetur...
73206 Ut Sadipscing ut-sadipscing@takimata.com dolor rebum...
84230 Nonumy Accusam nonumy-accusam@duo.com amet sanctus...
66429 Sit Aliquyam sit-aliquyam@sea.com takimata no...
51883 Justo Eos justo-eos@sed.com Stet amet...
test me

This example shows how displaytag can be configured in order to submit a form when paging or sorting, instead of using simple links.

This can be useful in order to maintain parameters from existing forms or in order to use parameters supplied by items inside the table tag together with custom ones. In this example this feature is used together with a table decorator in order to preserve the selection of checkboxes while paging.

For turning the use of forms on you will do to the following:

  • wrap the table tag in a form tag (give this form a name)
  • set the form attribute to the table tag using the name of such form

After doing that you will notice that links generated by displaytag will change in order to setup parameters in hidden fields and to submit the form using javascript. Note that displaytag doesn't create the form for you , you will need to create it as explained above or sorting/paging will not work.


The second step of this example show you how this feature can be used with a particular table decorator in order to add checkboxes to table rows and preserving the selection of such checkboxes while paging.

What you need to do is:

  • setup an instance of org.displaytag.decorator.CheckboxTableDecorator
  • Optionally sets the name of the field used as the id (checkbox value) using decorator.setId(***) in your object and the name of the checkbox itself using decorator.setFieldName(***) . The default id property name is id and the default name for checkboxes is _chk (you should not commonly need to change it).
  • Adds the decorator attribute to table tag in order to use this decorator and adds the name used for checkboxes to the excludedParams attribute
  • Adds a column <display:column property="checkbox" /> in your table, at a position of your like.
  • Test it!