List Model"

From Documentation
Line 6: Line 6:
 
[[Image:DrListModelRenderer.png]]
 
[[Image:DrListModelRenderer.png]]
  
As shown, listbox retrieves items from the specified model, and then invokes the renderer, if specified, to compose the [[ZK Component Reference/Data/Listbox/Listitem|listitem]] for the item.
+
As shown, listbox retrieves items from the specified model<ref>The listbox is smart enough to read the items that are visible at the client, such the items for the active page. It is called ''Live Data'' or ''Render on Demand'.'</ref>, and then invokes the renderer, if specified, to compose the [[ZK Component Reference/Data/Listbox/Listitem|listitem]] for the item.
  
 
The retrieval of items is done by invoking <javadoc method="getSize()" type="interface">org.zkoss.zul.ListModel</javadoc> and <javadoc method="getElementAt(int)" type="interface">org.zkoss.zul.ListModel</javadoc>.
 
The retrieval of items is done by invoking <javadoc method="getSize()" type="interface">org.zkoss.zul.ListModel</javadoc> and <javadoc method="getElementAt(int)" type="interface">org.zkoss.zul.ListModel</javadoc>.
  
 
The listbox will register itself as a data listener to the list model by invoking <javadoc method="addListDataListener(org.zkoss.zul.event.ListDataListener)" type="interface">org.zkoss.zul.ListModel</javadoc> Thus, if the list model is not mutable, the implementation has to notify all registered data listener. It is generally suggested to extend from <javadoc>org.zkoss.zul.AbstractListModel</javadoc> which provides a set of utilities for handling data listeners. Then, you need to only implement <javadoc method="getSize()" type="interface">org.zkoss.zul.ListModel</javadoc> and <javadoc method="getElementAt(int)" type="interface">org.zkoss.zul.ListModel</javadoc>.
 
The listbox will register itself as a data listener to the list model by invoking <javadoc method="addListDataListener(org.zkoss.zul.event.ListDataListener)" type="interface">org.zkoss.zul.ListModel</javadoc> Thus, if the list model is not mutable, the implementation has to notify all registered data listener. It is generally suggested to extend from <javadoc>org.zkoss.zul.AbstractListModel</javadoc> which provides a set of utilities for handling data listeners. Then, you need to only implement <javadoc method="getSize()" type="interface">org.zkoss.zul.ListModel</javadoc> and <javadoc method="getElementAt(int)" type="interface">org.zkoss.zul.ListModel</javadoc>.
 +
 +
<blockquote>
 +
----
 +
<references/>
 +
</blockquote>
  
 
= Small Amount of Data =
 
= Small Amount of Data =

Revision as of 09:45, 29 December 2010

Listbox and Grid allow developer to separate the view and the model by implementing ListModel. Once the model is assigned (with Listbox.setModel(ListModel)), the display of the listbox is controlled by the model, and an optional renderer. The model is used to provide data, while the renderer is used to provide the custom look. By default, the data is shown as a single-column grid/listbox. If it is not what you want, please refer to the View section for writing a custom renderer.

Model-driven Display

DrListModelRenderer.png

As shown, listbox retrieves items from the specified model[1], and then invokes the renderer, if specified, to compose the listitem for the item.

The retrieval of items is done by invoking ListModel.getSize() and ListModel.getElementAt(int).

The listbox will register itself as a data listener to the list model by invoking ListModel.addListDataListener(ListDataListener) Thus, if the list model is not mutable, the implementation has to notify all registered data listener. It is generally suggested to extend from AbstractListModel which provides a set of utilities for handling data listeners. Then, you need to only implement ListModel.getSize() and ListModel.getElementAt(int).


  1. The listbox is smart enough to read the items that are visible at the client, such the items for the active page. It is called Live Data or Render on Demand'.'

Small Amount of Data

Hug Amount of Data

Version History

Last Update : 2010/12/29


Version Date Content
     



Last Update : 2010/12/29

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