Package org.zkoss.stateless.state
Class IComboboxController<DataT>
- java.lang.Object
-
- org.zkoss.stateless.state.IComboboxController<DataT>
-
- All Implemented Interfaces:
ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
public class IComboboxController<DataT> extends java.lang.Object implements ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
AnIComboboxcontroller to control any operation on the given model.Note: this class is not thread-safe, so when it's used in multi-threading environment, the developer should handle the threading issue.
- Author:
- katherine
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IComboboxbuild()Returns the immutable combobox instance that the controller to build with.voidclear()Clears all the rendered data.org.zkoss.zul.ListModel<DataT>getModel()Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model.CheckedFunction2<DataT,java.lang.Integer,IComboitem>getRenderer()Returns the renderer to render each row, or null if the default renderer is used.intgetSelectedIndex()Returns the index of the selected item, or -1 if not selected.DataTgetSelectedObject()Returns the data object which is selected or null.static <D> IComboboxController<D>of(ICombobox owner, org.zkoss.zul.ListModel<D> model)Returns the controller instance with the givencombobox, andListModel.static <D> IComboboxController<D>of(ICombobox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D,java.lang.Integer,IComboitem> renderer)voidsetInvalidateThreshold(int invalidateThreshold)Sets the threshold number of changed items of a model to invalidate a widget's DOM elementsvoidsetModel(org.zkoss.zul.ListModel<DataT> model)Sets the list model associated with this combobox.voidsetRenderer(CheckedFunction2<DataT,java.lang.Integer,IComboitem> renderer)Sets the renderer which is used to render each row ifgetModel()is not null.voidsetSelectedIndex(int index)Deselects the currently selected items and selects the item with the given index.voidsetSelectedObject(DataT data)Sets the selected data object, or deselects it by passing a null value.
-
-
-
Method Detail
-
of
public static <D> IComboboxController<D> of(ICombobox owner, org.zkoss.zul.ListModel<D> model)
Returns the controller instance with the givencombobox, andListModel.- Parameters:
owner- The controller to control withmodel- The data model for the combobox.
-
of
public static <D> IComboboxController<D> of(ICombobox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D,java.lang.Integer,IComboitem> renderer)
- Parameters:
owner- The controller to control withmodel- The data model for the combobox.renderer- The data renderer for the combobox.
-
setModel
public void setModel(org.zkoss.zul.ListModel<DataT> model)
Sets the list model associated with this combobox. If a non-null model is assigned, no matter whether it is the same as the previous, it will always cause re-render.- Specified by:
setModelin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>- Parameters:
model- the list model to associate, or null to dissociate any previous model.- Throws:
org.zkoss.zk.ui.UiException- if failed to initialize with the model
-
setInvalidateThreshold
public void setInvalidateThreshold(int invalidateThreshold)
Sets the threshold number of changed items of a model to invalidate a widget's DOM elementsDefault:
10- Parameters:
invalidateThreshold- The threshold number
-
getModel
public org.zkoss.zul.ListModel<DataT> getModel()
Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model.- Specified by:
getModelin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
-
setRenderer
public void setRenderer(CheckedFunction2<DataT,java.lang.Integer,IComboitem> renderer)
Sets the renderer which is used to render each row ifgetModel()is not null.Note: changing a render will not cause the combobox to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(getModel())), or fire an
ListDataEventevent.- Specified by:
setRendererin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>- Parameters:
renderer- the renderer, or null to use the default.
-
getRenderer
public CheckedFunction2<DataT,java.lang.Integer,IComboitem> getRenderer()
Returns the renderer to render each row, or null if the default renderer is used.- Specified by:
getRendererin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
-
build
public ICombobox build()
Returns the immutable combobox instance that the controller to build with.- Specified by:
buildin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
-
clear
public void clear()
Description copied from interface:ItemControllerClears all the rendered data.- Specified by:
clearin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
-
getSelectedObject
public DataT getSelectedObject()
Returns the data object which is selected or null.Default:
null
-
setSelectedObject
public void setSelectedObject(DataT data)
Sets the selected data object, or deselects it by passing a null value.- Parameters:
data- The data object that contains in the model.
-
getSelectedIndex
public int getSelectedIndex()
Returns the index of the selected item, or -1 if not selected.
-
setSelectedIndex
public void setSelectedIndex(int index)
-
-