February 2005
Intermediate to advanced
528 pages
12h 53m
English
You want an easier way of displaying tabular data that supports paging and sorting.
Use the Display tag JSP tag library.
Example 4-13 shows a JSP page that displays the list of U.S. presidents using the model data from Recipe 4.5. This JSP page displays a table rendered using the display tag library. The displayed page has alternating table row colors, allows for paging, and offers column sorting, all without requiring any custom Java coding.
Example 4-13. Display tag example
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %> <html> <head> <title>Struts Cookbook - Chapter 4 : Display Tag Example</title> <style> .even {background-color:orange;} .odd {background-color:yellow;} </style> </head> <body> <h2>Display Tag Examples</h2> <jsp:useBean id="pagedData" class="com.oreilly.strutsckbk.ch04. PagedData"/> <display:table id="pres" name="${pagedData.data}" sort="list" pagesize="10" defaultsort="3"> <display:caption>United States Presidents</display:caption> <display:setProperty name="basic.show.header" value="true"/> <display:column property="firstName" title="First Name" sortable="true"/> <display:column property="lastName" title="Last Name" sortable="true"/> <display:column property="term" title="Term of Office" sortable="true"/> </display:table> </body> </html>
The display tag library is an open source tag library that can be used to render highly ...