Hello,

I have created a sample application which demo's similiar to the
myfaces pagedSortTable demo:

http://www.devosc.com/pub/myfaces-cars.zip

This demo has a new type of DataModel class called a PagedDataModel,
which will work with a ListDataModel, and presumably an
ArrayDataModel, it might work with the ResultDataModel but will not
work (atleast not straight away) with the ResultSetDataModel because
of its getRowCount method implementation.

This demo I believe is the most practical for real usage given the
wiki documentation.

[1] http://wiki.apache.org/myfaces/Working_With_DataTable_And_PreserveDataModel

As far as I can now tell there should be caveat that, that the
discussion is only in regard to having the whole dataset in memory,
given:

"as the data will be retrieved directly from the previously serialized data"

[2] http://wiki.apache.org/myfaces/WorkingWithLargeTables

The method setWrappedData is disabled making it not possible to update
the dataModel when sorting the dataTable and trying to work around it
causes duplicate queries to the database.

The following are observations made of the demo about the number of db
queries queries performed (potential in this case) in a requests
lifecyle given the respective settings, saving state method, bean
scope and preserveDataModel.

[2] client, request, false
[2] client, request, true
[2] server, request, false
[2] server, request, true

[1] client, session, false
[1] client, session, true
[1] server, session, false
[1] server, session, true

The number of calls to create the actual data model is denoted within
the square brackets.

Each test was redeployed and the browser session cookies removed.

So from the above, the only setting that ensures that the database
will not be queried more than once when either scrolling or sorting a
dataTable is if the managed bean is in the session scope and it would
also seem that the preserveDataModel attribute is of no consequence.

I did try to use the 1.1.2-SNAPSHOT jars but a javascript error occurs
related to the dataScroller. I would be interested in using/having the
latest jars that allow the demo to work.

What I would like to understand is why there are two queries being
performed when the bean is in the request scope ?

Reply via email to