Implement ListModel and TreeModel

From Documentation
Revision as of 01:16, 10 March 2011 by Tomyeh (talk | contribs)


Implement ListModel and TreeModel


The default implementation of models, such as ListModelList and DefaultTreeModel assumes all data are available in the memory. It is not practical if a model has a lot of data. For huge data, it is suggested to implement your own model by loading and caching only a portion of data at a time.

To implement your own model, you could extend from AbstractListModel, AbstractGroupsModel and DefaultTreeModel as described in the Model section. To implement a model that supports sorting, you have to implement ListModelExt too. Each time an user requires sorting, ListModelExt.sort(Comparator, boolean) will be called and the implementation usually clears the cache and re-generate the SQL statement accordingly.

Here is some pseudo code:


For a real example, please refer to Small Talk: Handling huge data using ZK.

Version History

Last Update : 2011/03/10


Version Date Content
     


Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.