myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg <dev...@gmail.com>
Subject A PagedListDataModel
Date Sat, 18 Mar 2006 14:55:49 GMT
Hi,

I'm still new to JSF and my first task has been to work on a reports
type page using tomahawks dataTable, commandSortHeader and
dataScroller.

So far, I've managed to get something whereby the dataTable's data is
being paginated and sorted.

Given the wiki document WorkingWithLargeTables, and also the column
sort requirement lead me to the attached script(s) which is based on
the pagedSortTable demo.

Basically I ended up creating a PagedListDataModel class that extends
the javax.faces.DataModel.

It follows closely to the existing javax.faces.ListDataModel class but
with the ability for the given List to have an independent dataset
size. And also some extra methods associated to the sort column and
ascending attribute(s).

It seems to work fairly well for what I need it to do at this time,
however the actionListener stuff in the setRowIndex method has not
been explicity tested.

I also noticed a difference between Sun's implementation and MyFaces
in regard to the setWrappedData method, where Sun would first set the
current index value to -1 directly before then passing actual desired
index value (zero) as a param to the setRowIndex method (in
setWrappedData). However MyFaces does not do this. Unless I'm
mistaken, please correct me, at the moment, I do think that Sun's
method is correct, because if by some means (e.g. an actionEvent) on
the first row (index=0) this row event handler itself wants to update
the the UIData's associated (List) data (via another call to
setWrappedData), then with the MyFaces implementation no
actionListener/Event will then occure because zero == zero, whereas
Sun's index = -1 trick ensures that even the first row can invoke the
actionListener/Events...

As said I havent had the need to consider a dataTable's
actionListeners, so my interpretation/reading of the code might be
mistaken.

The PagedListDataModel seems to be quite neat in that in ties together
the three Tomahawk components nicely.

However someone might be able to make a suggestion about the technique
used in the commandSortHeader actionListener method where the
dataModel's data is explicitly reset (via setWrappedData), this was
because it seemed needed to ensure that the UIData data was then
rebuilt/re-queried (in my case from the database) so that the data got
refreshed immediately.

I would probably have to do something similiar regardless because of
the additional query params required in the db query (filters etc) , I
couldn't firgure out a better or more applicable technique ?

--
Greg

Mime
View raw message