Class ISelectboxController<DataT>
- All Implemented Interfaces:
ItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
ISelectbox 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 instance that the controller to build withvoidclear()Clears all the rendered data.voidClears the selection.org.zkoss.zul.ListModel<DataT>getModel()Returns the model, which is set through byItemController.setModel(Object), or null.Returns the renderer, which is set through byItemController.setRenderer(CheckedFunction2), or a default one which is depended on implementation.intReturns the index of the selected item, or -1 if not selected.Returns the selected item, or null if no item is selected.Returns all selected items, or an empty set if no item is selected.booleanReturns whether it is multiple selection.static <D> ISelectboxController<D>of(ISelectbox owner) Returns the controller instance with the givenselectbox.static <D> ISelectboxController<D>of(ISelectbox owner, org.zkoss.zul.ListModel<D> model) Returns the controller instance with the givenselectboxstatic <D> ISelectboxController<D>of(ISelectbox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<Object, Integer, String> renderer) Returns the controller instance with the givenselectboxvoidSets the given model to this controller.voidsetMultiple(boolean multiple) Sets whether multiple selections are allowed.voidsetRenderer(CheckedFunction2<DataT, Integer, String> renderer) Sets the renderer which is used to render each data ifItemController.getModel()is not null.voidsetSelectedIndex(int jsel) Deselects the currently selected items and selects the item with the given index.voidsetSelectedObject(DataT item) Deselects all the currently selected items and selects the given item.voidsetSelectedObjects(Set<DataT> items) Sets all selected items.
-
Method Details
-
of
Returns the controller instance with the givenselectbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the selectbox.
-
of
public static <D> ISelectboxController<D> of(ISelectbox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<Object, Integer, String> renderer) Returns the controller instance with the givenselectbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the selectbox.renderer- The renderer of the list model.
-
of
Returns the controller instance with the givenselectbox.Note: The selectbox must contain as least one child, which will covert them into a model automatically
- Parameters:
owner- The controller to control with
-
setModel
Description copied from interface:ItemControllerSets the given model to this controller.Note: calling this method after
ItemController.build(), you should invokeItemController.build()again to take effect to replace the current one at client.
For example,uiAgent.replaceWith(locator, itemController.build());Default:
null- Specified by:
setModelin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
getModel
Description copied from interface:ItemControllerReturns the model, which is set through byItemController.setModel(Object), or null.- Specified by:
getModelin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
setRenderer
Description copied from interface:ItemControllerSets the renderer which is used to render each data ifItemController.getModel()is not null.Note: calling this method after
ItemController.build(), you should invokeItemController.build()again to take effect to replace the current one at client.
For example,uiAgent.replaceWith(locator, itemController.build());Default:
null, or depended on the implementation- Specified by:
setRendererin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
getRenderer
Description copied from interface:ItemControllerReturns the renderer, which is set through byItemController.setRenderer(CheckedFunction2), or a default one which is depended on implementation.- Specified by:
getRendererin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
setMultiple
public void setMultiple(boolean multiple) Sets whether multiple selections are allowed.Notice that, if a model is assigned, it will change the model's state (by
Selectable.setMultiple(boolean)). -
isMultiple
public boolean isMultiple()Returns whether it is multiple selection.Default:
false -
build
Description copied from interface:ItemControllerReturns the immutable instance that the controller to build with- Specified by:
buildin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
clear
public void clear()Description copied from interface:ItemControllerClears all the rendered data.- Specified by:
clearin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISelectbox, String>
-
getSelectedIndex
public int getSelectedIndex()Returns the index of the selected item, or -1 if not selected. -
setSelectedIndex
public void setSelectedIndex(int jsel) Deselects the currently selected items and selects the item with the given index. -
getSelectedObject
Returns the selected item, or null if no item is selected. -
setSelectedObject
Deselects all the currently selected items and selects the given item. -
getSelectedObjects
Returns all selected items, or an empty set if no item is selected. -
setSelectedObjects
Sets all selected items.Note:
isMultiple()should be true.- Parameters:
items- The set of the data in the model.
-
clearSelection
public void clearSelection()Clears the selection.
-