Acquiring your List of data

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
45635 Eos Diam eos-diam@sed.com EOS duo eos...
9238 Sanctus Eirmod sanctus-eirmod@rebum.com LOREM labore dolor...
18241 Gubergren At gubergren-At@gubergren.com LOREM invidunt dolore...
76392 Diam Sit diam-sit@eos.com SED elitr takimata...
53137 Labore Gubergren labore-gubergren@sadipscing.com ET voluptua et...
64866 Diam Clita diam-clita@consetetur.com CONSETETUR dolores Stet...
223 Dolor Elitr dolor-elitr@ut.com DIAM vero ea...
78335 Ut Sit ut-sit@aliquyam.com LOREM tempor amet...
27388 Dolore Et dolore-et@eirmod.com EA sanctus duo...
62886 Takimata Est takimata-est@Stet.com ALIQUYAM rebum nonumy...

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
37862 Clita Dolores clita-dolores@sed.com ALIQUYAM aliquyam sanctus...
32229 Ea Sea ea-sea@et.com DOLORE nonumy nonumy...
19263 Nonumy Eirmod nonumy-eirmod@et.com SED sed Stet...
14505 Nonumy Erat nonumy-erat@ipsum.com EOS sanctus sadipscing...
97682 Justo Diam justo-diam@voluptua.com NO eirmod vero...
89188 Amet Nonumy amet-nonumy@kasd.com VOLUPTUA voluptua est...
84227 Vero Et vero-et@sit.com ACCUSAM amet ea...
72710 Et Ut et-ut@sed.com EIRMOD takimata dolores...
18792 Invidunt Et invidunt-et@amet.com JUSTO labore et...
51552 Ut Est ut-est@magna.com DOLORES no vero...
5726 Consetetur Rebum consetetur-rebum@Stet.com TEMPOR Lorem erat...
30426 Ea Ipsum ea-ipsum@ipsum.com ET duo amet...
25194 Elitr Et elitr-et@justo.com ET tempor et...
16229 Dolore Aliquyam dolore-aliquyam@labore.com EA est nonumy...
49050 Erat Voluptua erat-voluptua@est.com SED gubergren nonumy...

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.