Hi Luke,

Just some background for other people who may be reading: the Session State Manager determines what part of the model will be saved in the session, and what part will be "recreated" when the next request occurs. This helps you control the size of the session data.

For example, the FullTableSessionStateManager saves _everything_ into the session -- data, column model, paging and sorting state. This is the simplest approach, but it is obviously not desirable if the data is big and the column model is constant.

The SimpleTableSessionStateManager saves only the paging and sorting state, which is tiny, and assumes that both the column model and the data model (but not necessarily the data itself) are constant. It uses them together with the table state to recreate the full table model every time it is required (usually at the beginning of a new request).

The most common case where you can use this session manager is when you display data from a database. To do this, create a custom TableDataModel that loads the data from the database (see below). Create just one instance per application (or per component/page) of the TableDataModel and the TableColumnModel that defines the table columns. Then create just one instance of the SimpleTableSessionStateManager using those two objects in its constructor. That object is then passed as a 'tableSessionStateManager' binding to the table component. One place that can be used to initialize those objects is finishLoad() -- it will be done once, rather than at every request.

To implement a custom TableDataModel, you can start by extending AbstractTableDataModel (which takes care of the pesky listener methods) and override the methods getTableRows() and getTableRowsCount() to load the data. That's all.

Please keep in mind that in this approach it is the table model that performs the sorting of the data. If your persistence method allows data to be extracted already sorted and possibly limited to the current page, it would probably be best to create your own implementation of a table model that uses the table state to perform those actions. As I have mentioned earlier, there is now such a model that uses plain SQL to load its data.

I hope this helps.

Best regards,

-mb

 

Luke Galea <[EMAIL PROTECTED]> wrote:

Quick question about the contrib. table component.. what is the preferred way of supplying a session state manager? If I was to want to slightly modify the example to use a simple state manager instead of a  full.. how would I do so? The constructor for simple state manager takes a data and column model.. which I have already supplied in creating my model.. should I store these and use them later?? Am I missing something?

 

Thanks

 

Luke Galea

Software Development

BlueCat Networks

905-762-5225

 



Do you Yahoo!?
U2 on LAUNCH - Exclusive medley & videos from Greatest Hits CD

Reply via email to