Up until this point, we have simply had a List object available to us under the name "list" in the request scope that has driven the display of the tables shown. We have been setting up that bean with the following scriptlet, but presumably you would be doing something similar in your Action class rather then raw on this jsp page.
<% request.setAttribute( "test", new TestList( 10 ) ); %>
This table is called with the following attributes:
<display:table name="test">
| ID | Name | Status | Comments | |
|---|---|---|---|---|
| 91742 | Eos Diam | eos-diam@invidunt.com | STET | sanctus aliquyam... |
| 78238 | Gubergren Dolor | gubergren-dolor@sit.com | INVIDUNT | clita consetetur... |
| 18671 | Tempor Nonumy | tempor-nonumy@eos.com | AT | ipsum Stet... |
| 39825 | Kasd Sed | kasd-sed@invidunt.com | ET | diam et... |
| 35083 | Eos Tempor | eos-tempor@consetetur.com | ET | nonumy justo... |
| 99052 | Clita Diam | clita-diam@Stet.com | EST | amet ipsum... |
| 91929 | Diam Sadipscing | diam-sadipscing@est.com | DOLORE | no et... |
| 16460 | Est Lorem | est-Lorem@sea.com | DIAM | voluptua sed... |
| 65798 | Erat Eirmod | erat-eirmod@eos.com | ET | et sea... |
| 39241 | Invidunt No | invidunt-no@At.com | CONSETETUR | est est... |
But, like other struts tags, you can acquire a handle to the list you want to display by specifying not only a bean name, but also a bean property (a getter method), and the table tag will call that property to fetch the list to display.
The value of the name attribute can be expressed with a syntax similar to EL of JSTL.
You can define the scope of the bean adding one of the following suffix:
You can also access javabean style properties, mapped properties or indexed properties in the bean, also nested!.
The syntax for accessing a javabean property is .property. You can read a mapped property specifying it
between () and an indexed property using [].
So the following:
sessionScope.list.value.attribute(name).item[1]is equivalent to:
session.getAttribute("list").getValue().getAttribute("name").getItem(1)The lists above and below are both generated randomly each time you come to this page, but since this list of data is attached to your session, it should remain the same through page refreshes.
This table is called with the following attributes:
<display:table name="sessionScope.holder.list">
| ID | Name | Status | Comments | |
|---|---|---|---|---|
| 39096 | Ipsum Amet | ipsum-amet@amet.com | VERO | diam sadipscing... |
| 92978 | Takimata Ipsum | takimata-ipsum@amet.com | ET | labore Lorem... |
| 47730 | Tempor No | tempor-no@no.com | VOLUPTUA | rebum nonumy... |
| 69374 | Magna Stet | magna-Stet@At.com | UT | sit invidunt... |
| 14096 | Elitr Duo | elitr-duo@consetetur.com | ELITR | kasd justo... |
| 64566 | Ut Et | ut-et@labore.com | AMET | justo consetetur... |
| 6861 | Sit Sadipscing | sit-sadipscing@tempor.com | SADIPSCING | sea clita... |
| 48758 | Clita Sed | clita-sed@ea.com | SANCTUS | clita sanctus... |
| 96535 | Diam Gubergren | diam-gubergren@duo.com | DIAM | kasd Stet... |
| 86638 | Ipsum Amet | ipsum-amet@ut.com | ELITR | Lorem accusam... |
| 91369 | Clita Sed | clita-sed@sit.com | ACCUSAM | amet elitr... |
| 28388 | Sed At | sed-At@ea.com | LOREM | gubergren nonumy... |
| 69001 | Justo Erat | justo-erat@et.com | DOLORES | takimata vero... |
| 24923 | Consetetur Ipsum | consetetur-ipsum@sed.com | NO | justo consetetur... |
| 33622 | Sit Elitr | sit-elitr@Stet.com | EST | magna est... |
By default, if you supply the table tag with either a null object, or an empty list, it won't generate any tables at all, but it will display a message says "Nothing found to display"..
You can override this message using a <setProperty> tag or a custom properties file.
See Config, overriding default behaviors/messages page.