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 Object
implements ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
An
ICombobox controller 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
Modifier and TypeMethodDescriptionbuild()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.Returns the renderer to render each row, or null if the default renderer is used.intReturns the index of the selected item, or -1 if not selected.Returns the data object which is selected or null.static <D> IComboboxController<D>Returns the controller instance with the givencombobox, andListModel.static <D> IComboboxController<D>of(ICombobox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D, Integer, IComboitem> renderer) Returns the controller instance with the givencombobox,ListModel, andCheckedFunction2<D,Integer, IComboitem> voidsetInvalidateThreshold(int invalidateThreshold) Sets the threshold number of changed items of a model to invalidate a widget's DOM elementsvoidSets the list model associated with this combobox.voidsetRenderer(CheckedFunction2<DataT, 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 Details
-
of
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, Integer, IComboitem> renderer) Returns the controller instance with the givencombobox,ListModel, andCheckedFunction2<D,Integer, IComboitem> - Parameters:
owner- The controller to control withmodel- The data model for the combobox.renderer- The data renderer for the combobox.
-
setModel
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
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
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
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
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
Returns the data object which is selected or null.Default:
null -
setSelectedObject
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)
-