Hi,
As you mention, IBasicTableModel tells you what the current sorting and
paging states are. As a result, it allows you to send custom queries to
the database (usually including LIMIT, OFFSET, and ORDER sql modifiers)
that only return the data that is on the current page, rather than the
full set. The effect is that the communication with the database is
greatly reduced and the processing is performed within the database
itself, rather then on the web server.
Please note that if the table data is provided in an array, Table also
stores only the sorting within the session. However, if the array is in
a persistent property, it will be persisted in the session. You
therefore have the following options when using an array:
- store the array in a persistent property and increase the size of the
session accordingly
- do not use a persistent property, but make a query to the database
whenever the data is requested. That will keep the session small, but
will increase the communication between the database and the web server,
and will perform the sorting and paging on the web server as well.
I would therefore suggest to start with a persistent array as it is
rather easy, but for hard core applications to use the IBasicTableModel
approach instead.
One other thing: in general it is a good idea to use lazy loading in
this case. In other words, to prepare the data when it is requested,
rather than in pageBeginRender -- this helps with listeners that may be
invoked before pageBeginRender.
Best regards,
-mb
Skriloff, Nicholas wrote:
For this question assume that the data passed into a table component
comes from a persistent property-specification, usually initialize in
pageBeginRender.
The contrib table model component accepts the data in many forms. But,
two of them are an object[] or IBasicTableModel. What is the advantage
of doing one over the other in terms of processing? It seems that if
your data is IBasicTableModel then you will only store meta-data but
will hit the database between calls for things like paging. If the you
pass in an object array, then the whole array is stored in memory but
there are less database queries for things like paging. Is this Close?
This code below is taken from TableView.java
// if the source parameter is of type [EMAIL PROTECTED] IBasicTableModel},
// create and return an appropriate wrapper
if (objSourceValue instanceof IBasicTableModel)
return new BasicTableModelWrap(
(IBasicTableModel) objSourceValue,
objColumnModel,
objState);
// otherwise, the source parameter must contain the data to be
displayed
ITableDataModel objDataModel = null;
if (objSourceValue instanceof Object[])
objDataModel = new SimpleListTableDataModel((Object[])
objSourceValue);
else if (objSourceValue instanceof List)
objDataModel = new SimpleListTableDataModel((List)
objSourceValue);
else if (objSourceValue instanceof Collection)
objDataModel = new SimpleListTableDataModel((Collection)
objSourceValue);
else if (objSourceValue instanceof Iterator)
objDataModel = new SimpleListTableDataModel((Iterator)
objSourceValue);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]