I opened the JPetstore demo and it makes use of the PaginatedList, but does so
through another class, called BeanAction, and also uses Struts logic and
bean:define tags for working with the list.
Is there an example out there that uses JSTL? I have something working right
now, but I'm concerned about my page now having scriptlet code in it.
Specifically, action prior to the page calls the sqlmap.queryForPaginatedList,
then puts the list in the session, along with a list count. The count is
really only used to determine if the page needs to show a table, or a message
that no records were found. The top of the page uses this scriptlet code
though:
<%
PaginatedList list = (PaginatedList) pageContext.getAttribute("sfsaved");
pageContext.setAttribute("pageSize", new Integer( list.getPageSize() ) );
pageContext.setAttribute("pageIndex", new Integer( list.getPageIndex() ) );
pageContext.setAttribute("previousPageAvailable",
new Boolean( list.isPreviousPageAvailable() ) );
pageContext.setAttribute("nextPageAvailable",
new Boolean( list.isNextPageAvailable() ) );
%>
The code is so I can display rec# as a column:
<c:out value="${mystat.count + pageScope.pageIndex * pageScope.pageSize }" />
And, so my [previous page] and [next page] buttons can be dynamic:
<c:choose>
<c:when test="${pageScope.previousPageAvailable}">
<input type="submit" name="event" value="<bean:message
key="button.Water_Reports.previousSet" />" />
</c:when>
<c:otherwise>
<input type="submit" name="event" value="<bean:message
key="button.Water_Reports.previousSet" />" disabled="disabled" />
</c:otherwise>
</c:choose>
So, is this the "right way" of doing things, or am I going about it all wrong?
I appreciate any feedback on this one. I just started using iBatis a few days
ago, and definitely want to adhere to the best practices.
Eric