Hey Tom!
Thanks for your reply.
I tried to get the paging control working this morning (I'm using an
ArrayList for my DataSource, so I "think" I'm OK with rowId (per your
email below) -- but not totally sure...<s>).
I stuck the DataScrollActionListener and the images directory in the
same directory with the JSP, added the rowId and ID fields to the data
table, tried to run it, and got this:
javax.faces.FacesException: javax.servlet.ServletException: javax.servlet.jsp.JspException: DataScrollerActionListener
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:327)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
Here's my table definition:
<t:dataTable
id = "Data"
// style classes omitted for clarity
width="100%"
var="tx"
rows="10"
rowId="#(tx.accountName}"
value="#{TD.txs}"
sortColumn="#{TD.sortColumn}"
sortAscending="#{TD.ascending}"
preserveDataModel="true" preserveSort="true">
I'm able to run the data table fine and sort all the columns if I
remove the new paging code below.
(I was unable to find the style classes below in the source so I'm
assuming they're "built in")
<t:dataScroller id="scroll_1"
for=""
fastStep="10"
pageCountVar="pageCount"
pageIndexVar="pageIndex"
styleClass="scroller"
paginator="true"
paginatorMaxPages="9"
paginatorTableClass="paginator"
paginatorActiveColumnStyle="font-weight:bold;">
<f:actionListener
type="DataScrollerActionListener" />
<f:facet name="first">
<t:graphicImage
url="" border="1" />
</f:facet>
<f:facet name="last">
<t:graphicImage
url="" border="1" />
</f:facet>
<f:facet name="previous">
<t:graphicImage
url="" border="1" />
</f:facet>
<f:facet name="next">
<t:graphicImage
url="" border="1" />
</f:facet>
<f:facet name="fastforward">
<t:graphicImage
url="" border="1" />
</f:facet>
<f:facet name="fastrewind">
<t:graphicImage
url="" border="1" />
</f:facet>
</t:dataScroller>
</h:panelGrid>
There's no code in the DataScrollerActionListener so maybe that's the
problem?
Also, I'm not sure what you are doing with your <f:params...>
below. The example doesn't use them or the output format tag. (I'm sure
I'll get fancier once I get the basic thing working...<s>).
In any case, you may have run into this problem. It looks "basic", but
I don't see it right off.
Thanks in advance.
Mike
Tom Butler wrote:
Mike,
I was able to get the paging control to work fairly easily (much easier than
the column sort which took a few days) - here's my code that I leveraged
from the examples:
<h:panelGrid columns="1" styleClass="scrollerTable2"
columnClasses="standardTable_ColumnCentered">
<t:dataScroller id="scroll_1" for="" fastStep="10"
pageCountVar="pagecount" pageIndexVar="pageindex" paginatorMaxPages="9"
paginator="true" paginatorActiveColumnStyle="font-weight:bold;"
rendered="#{searchproviders_bean.dm_searchresults.rowCount > 10}">
<f:facet name="previous">
<t:graphicImage url="" border="1" />
</f:facet>
<f:facet name="next">
<t:graphicImage url="" border="1" />
</f:facet>
</t:dataScroller>
<t:dataScroller id="scroll_2" for="" rowsCountVar="rowsCount"
displayedRowsCountVar="displayedRowsCountVar"
firstRowIndexVar="firstRowIndex" lastRowIndexVar="lastRowIndex"
pageCountVar="pageCount" pageIndexVar="pageIndex">
<h:outputFormat value="#{example_messages['dataScroller_pages']}"
styleClass="standard">
<f:param value="#{rowsCount}" />
<f:param value="#{displayedRowsCountVar}" />
<f:param value="#{firstRowIndex}" />
<f:param value="#{lastRowIndex}" />
<f:param value="#{pageIndex}" />
<f:param value="#{pageCount}" />
</h:outputFormat>
</t:dataScroller>
</h:panelGrid>
The output format message bundle can be found in the
example_messages.properties found in the myfaces examples:
dataScroller_pages = {0} Cars found, displaying {1} cars, from {2} to {3}.
Page {4} / {5}
Note the <t:dataTable id="data"..> needs to match the <t:dataScroller
for=""...>
Also note, I've added the "rendered" attribute for the first datascroller:
rendered="#{searchproviders_bean.dm_searchresults.rowCount > 10}"
The purpose for using rendered is to not display the paging controls if
there is not enough data to page (in my case < 10 rows.)
I am only able to get rendered to work if I use a DataModel (which has a
rowCount attribute) as the data source. I tried to use the MyFaces
#{rowsCount} var without success (maybe someone knows how to do this.
Finally, I'm going to try to extend this so that the 'previous' page control
does not display if the user is on the first page of data, and so that the
'next' page control does not display if the user is on the last page of data
(similar to how google search results work), though I have not found a way
to do this yet? Any Ideas from anyone on this?
Thanks
Tom
-----Original Message-----
From: Mike [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 01, 2006 8:59 AM
To: MyFaces Discussion
Subject: Paging Control
Hi all,
Is there anything special (any "gotchas") to watch out for with the
paging control or is it relatively straightforward to get working?
Thanks.
Mike
|