Package org.zkoss.stateless.state
Class IComboboxController<Data>
- java.lang.Object
-
- org.zkoss.stateless.state.IComboboxController<Data>
-
- All Implemented Interfaces:
ItemController<Data,ListModel<Data>,ICombobox,IComboitem>
public class IComboboxController<Data> extends java.lang.Object implements ItemController<Data,ListModel<Data>,ICombobox,IComboitem>
AnICombobox
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ICombobox
build()
Returns the immutable combobox instance that the controller to build with.void
clear()
Clears all the rendered data.ListModel<Data>
getModel()
Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model.CheckedFunction2<Data,java.lang.Integer,IComboitem>
getRenderer()
Returns the renderer to render each row, or null if the default renderer is used.int
getSelectedIndex()
Returns the index of the selected item, or -1 if not selected.Data
getSelectedObject()
Returns the data object which is selected or null.static <D> IComboboxController<D>
of(ICombobox owner, ListModel<D> model)
static <D> IComboboxController<D>
of(ICombobox owner, ListModel<D> model, CheckedFunction2<D,java.lang.Integer,IComboitem> renderer)
void
setInvalidateThreshold(int invalidateThreshold)
Sets the threshold number of changed items of a model to invalidate a widget's DOM elementsvoid
setModel(ListModel<Data> model)
Sets the list model associated with this combobox.void
setRenderer(CheckedFunction2<Data,java.lang.Integer,IComboitem> renderer)
Sets the renderer which is used to render each row ifgetModel()
is not null.void
setSelectedIndex(int index)
Deselects the currently selected items and selects the item with the given index.void
setSelectedObject(Data 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, ListModel<D> model)
- Parameters:
owner
- The controller to control withmodel
- The data model for the combobox.
-
of
public static <D> IComboboxController<D> of(ICombobox owner, 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(ListModel<Data> 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:
setModel
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
- Parameters:
model
- the list model to associate, or null to dissociate any previous model.- Throws:
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 ListModel<Data> getModel()
Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model.- Specified by:
getModel
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
-
setRenderer
public void setRenderer(CheckedFunction2<Data,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
ListDataEvent
event.- Specified by:
setRenderer
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
- Parameters:
renderer
- the renderer, or null to use the default.
-
getRenderer
public CheckedFunction2<Data,java.lang.Integer,IComboitem> getRenderer()
Returns the renderer to render each row, or null if the default renderer is used.- Specified by:
getRenderer
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
-
build
public ICombobox build()
Returns the immutable combobox instance that the controller to build with.- Specified by:
build
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
-
clear
public void clear()
Description copied from interface:ItemController
Clears all the rendered data.- Specified by:
clear
in interfaceItemController<Data,ListModel<Data>,ICombobox,IComboitem>
-
getSelectedObject
public Data getSelectedObject()
Returns the data object which is selected or null.Default:
null
-
setSelectedObject
public void setSelectedObject(Data 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)
-
-