View source

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 Email Status Comments
5352 Ea Diam ea-diam@et.com DOLORE takimata diam...
50343 Sadipscing Sadipscing sadipscing-sadipscing@kasd.com NONUMY sed rebum...
18948 Nonumy Sit nonumy-sit@sea.com ET sea Lorem...
40601 Et Dolor et-dolor@elitr.com CLITA Stet et...
87288 Gubergren Sed gubergren-sed@rebum.com MAGNA amet diam...
25582 Invidunt Consetetur invidunt-consetetur@At.com DOLORES diam est...
27816 Elitr Rebum elitr-rebum@sadipscing.com DOLORES et sanctus...
29349 Tempor Est tempor-est@voluptua.com ALIQUYAM sea Lorem...
40954 Vero Consetetur vero-consetetur@et.com DOLORES dolore et...
87866 Kasd Ea kasd-ea@dolore.com MAGNA Lorem elitr...

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:

  • pageScope
  • requestScope (default)
  • sessionScope
  • applicationScope

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 Email Status Comments
1054 Aliquyam Sit aliquyam-sit@magna.com SED amet sadipscing...
24443 Ut Dolore ut-dolore@et.com NONUMY vero diam...
70625 Eos Vero eos-vero@Lorem.com DIAM duo ut...
42171 Justo Voluptua justo-voluptua@takimata.com KASD sea justo...
29395 Dolores Amet dolores-amet@ut.com DOLORES ea nonumy...
80109 Accusam Sed accusam-sed@gubergren.com SEA gubergren sed...
26907 Dolor Stet dolor-Stet@dolore.com VOLUPTUA voluptua ea...
99772 Takimata Est takimata-est@ea.com AMET vero invidunt...
95351 Diam Rebum diam-rebum@accusam.com ET takimata diam...
47135 Ea Ipsum ea-ipsum@et.com EIRMOD diam eirmod...
10224 Vero Accusam vero-accusam@invidunt.com EST elitr nonumy...
34083 Rebum At rebum-At@ipsum.com IPSUM sit At...
54172 Et Accusam et-accusam@diam.com ERAT et tempor...
86093 Tempor Et tempor-et@ea.com ET magna gubergren...
38054 Ipsum Est ipsum-est@dolore.com REBUM est gubergren...

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.

Nothing found to display.