org.zkoss.zul
Interface ListitemRendererExt


public interface ListitemRendererExt

Provides additional control to ListitemRenderer.

Author:
tomyeh
See Also:
ListitemRenderer

Field Summary
static int DETACH_ON_RENDER
          Returned by getControls() to indicate to detach the list cell adde by newListcell(org.zkoss.zul.Listitem).
static int DETACH_ON_UNLOAD
          Returned by getControls() to indicate whether to detach a rendered item when unloading it.
 
Method Summary
 int getControls()
          Returns how a listbox shall render the live data.
 Listcell newListcell(Listitem item)
          Create an instance of Listcell as the first cell of the list item.
 Listitem newListitem(Listbox listbox)
          Creates an instance of Listitem for rendering.
 

Field Detail

DETACH_ON_RENDER

static final int DETACH_ON_RENDER
Returned by getControls() to indicate to detach the list cell adde by newListcell(org.zkoss.zul.Listitem).

To simplify the implementation of ListitemRenderer.render(org.zkoss.zul.Listitem, java.lang.Object), Listbox, by default, detached the list cell before calling ListitemRenderer.render(org.zkoss.zul.Listitem, java.lang.Object) -- as if this flag is returned.

If you don't specify this flag, the implementation of ListitemRenderer.render(org.zkoss.zul.Listitem, java.lang.Object) must be aware of the existence of the first cell (of the passed list item).

See Also:
Constant Field Values

DETACH_ON_UNLOAD

static final int DETACH_ON_UNLOAD
Returned by getControls() to indicate whether to detach a rendered item when unloading it.

When an item has to be cleaned up (so it can be re-rendered again), the list box checks whether this flag is returned. For example, when a new data model is assigned, all rendered items (i.e., generated by ListitemRenderer.render(org.zkoss.zul.Listitem, java.lang.Object)) will be cleaned up.

To have the best performance, the list box, by default, keep using the same list item and the first list cell (other list cells, if any, are removed).

Sometimes it could be an issue. For example, you assign attributes or annotations to a rendered item. Then, you'd better to return this flag to indicate that. a new list item shall be created (by calling newListitem(org.zkoss.zul.Listbox) and newListcell(org.zkoss.zul.Listitem)) to replace the renderred item.

See Also:
Constant Field Values
Method Detail

newListitem

Listitem newListitem(Listbox listbox)
Creates an instance of Listitem for rendering. The created component will be passed to ListitemRenderer.render(org.zkoss.zul.Listitem, java.lang.Object).

Note: remember to invoke AbstractComponent.applyProperties() to initialize the properties, defined in the component definition, properly.

If null is returned, the default list item is created as follow.


final Listitem item = new Listitem();
item.applyProperties();
return item;

Note: DO NOT call Listitem.setParent(org.zkoss.zk.ui.Component).

Returns:
the list item if you'd like to create it differently, or null if you want Listbox to create it for you

newListcell

Listcell newListcell(Listitem item)
Create an instance of Listcell as the first cell of the list item.

Note: remember to invoke AbstractComponent.applyProperties() to initialize the properties, defined in the component definition, properly.

Note: DO NOT call Listitem.setParent(org.zkoss.zk.ui.Component). Don't create cells for other columns.

If null is returned, the default list cell is created as follow.


final Listcell cell = new Listcell();
cell.applyProperties();
return cell;

Note: DO NOT call Listcell.setParent(org.zkoss.zk.ui.Component).

Parameters:
item - the list item. It is the same as that is returned by newListitem(org.zkoss.zul.Listbox)
Returns:
the list cell if you'd like to create it differently, or null if you want Listbox to create it for you

getControls

int getControls()
Returns how a listbox shall render the live data.

Note: if this interface is not implemented, DETACH_ON_RENDER is assumed.

Returns:
a combination of DETACH_ON_RENDER and DETACH_ON_UNLOAD to indicate how to render the live data.


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.