I found an interesting article about dataTable, dataScroller and large
database :
http://wiki.apache.org/myfaces/WorkingWithLargeTables
You can found a working example of this implementation :
http://wiki.apache.org/myfaces-data/attachments/WorkingWithLargeTables/attachments/myfaces-cars.zip
Hope this help
Alexandre Jaquet wrote:
Hi Tom,
I encounter some trouble to, if you find the way please post back a
working example.Then we can have a simple working tutorial.
Regards.
Alexandre Jaquet
Tom Innes wrote:
We are trying to use Tomahawk datatable and datascroller with command
links in the list. We also want each column to be sortable. For
example a List of Countries that have Country Codes and Country Names.
We have tried various things and have something that comes close. The
issue we have left is that if you edit a Country on another Page say
page 2 and save that country we lose the page that the user was on.
Here is some code snippets from what we are doing. We are using
tomahawk 1.1.3
<h:panelGroup id="countryListBody">
<t:dataTable id="countryListData"
styleClass="scrollerTable"
headerClass="standardTable_Header"
footerClass="standardTable_Header"
rowClasses="standardTable_Row1,standardTable_Row1"
columnClasses="standardTable_Column,standardTable_Column,standardTable_Column"
var="countryRow"
value="#{countryQBEController.listController.dataModel}"
rows="10"
sortColumn="#{countryQBEController.listController.sortColumn}"
sortAscending="#{countryQBEController.listController.ascending}"
preserveSort="true"
>
<t:column sortable="true">
<f:facet name="header">
<h:outputText value= "Country Code"/>
</f:facet>
<h:outputText value="#{countryRow.countryCode}" />
</t:column>
<t:column sortable="true">
<f:facet name="header">
<h:outputText value= "Country Name"/>
</f:facet>
<h:outputText value="#{countryRow.name}" />
</t:column>
<t:column sortable="false">
<f:facet name="header">
<h:outputText value="Edit" />
</f:facet>
<t:commandLink action="#{countryFormController.action.edit}"
id="editLink" value="Edit"/>
</t:column>
</t:dataTable>
<h:panelGrid columns="1" styleClass="scrollerTable2"
columnClasses="standardTable_Column" >
<t:dataScroller id="scroll_1"
for="countryListData"
fastStep="10"
pageCountVar="pageCount"
pageIndexVar="pageIndex"
styleClass="scroller"
paginator="true"
paginatorMaxPages="9"
paginatorTableClass="paginator"
paginatorActiveColumnStyle="font-weight:bold;" >
<f:facet name="first" >
<t:graphicImage url="/images/arrow-first.gif" border="1" />
</f:facet>
<f:facet name="last">
<t:graphicImage url="/images/arrow-last.gif" border="1" />
</f:facet>
<f:facet name="previous">
<t:graphicImage url="/images/arrow-previous.gif" border="1" />
</f:facet>
<f:facet name="next">
<t:graphicImage url="/images/arrow-next.gif" border="1" />
</f:facet>
<f:facet name="fastforward">
<t:graphicImage url="/images/arrow-ff.gif" border="1" />
</f:facet>
<f:facet name="fastrewind">
<t:graphicImage url="/images/arrow-fr.gif" border="1" />
</f:facet>
</t:dataScroller>
<t:dataScroller id="scroll_2"
for="countryListData"
pageCountVar="pageCount"
pageIndexVar="pageIndex"
>
<h:outputFormat value="Page {0} of {1}" styleClass="standard" >
<f:param value="#{pageIndex}" />
<f:param value="#{pageCount}" />
</h:outputFormat>
</t:dataScroller>
</h:panelGrid>
</h:panelGroup>
Some things we have noticed that lead us to believe we are doing
something wrong.
1. If you specify preserveDataModel = “true” on the datatable we
will get a stack trace
_java.lang.IllegalArgumentException_: row is unavailable
_After re_-peated Paging and Clicking on the Comand Link to Edit the Row
_As well Editting Edits the wrong Record_
2. The examples we have suggest the sortColumn and sortAscending
properties need to be specified on the data table and stored in
a backing bean and yet they appear to not be required. Just
saying sortable=”true” on the t:column works. Is this the
intended behaviour?
3. If we set the value on the datatable directly to a Results List
instead of the DataModel then the Command Links don’t work. (
Always Edits First Row in the List)
4. If in our backing bean we don’t have a SetDataModel we get a
stack trace. If we code the setter and have it set the
DataModel then paging doesn’t work. Right now we have the
method, but it does nothing.
If anybody could advise how the datatable and datascroller should be
configured to work with sorting, command links in the list and paging
it would be appreciated.
Also the Tomahawk examples at irian don’t contain an example with all
these features enabled so we are unclear how we can implement these
features.