Package org.zkoss.stateless.state
Class IChosenboxController<DataT>
java.lang.Object
org.zkoss.stateless.state.IChosenboxController<DataT>
- All Implemented Interfaces:
ItemController<DataT,ListModel<DataT>, IChosenbox, String>
public class IChosenboxController<DataT>
extends Object
implements ItemController<DataT,ListModel<DataT>,IChosenbox,String>
An
IChosenbox 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 TypeMethodDescriptionvoidAdd an item into selection.build()Returns the immutable instance that the controller to build withvoidclear()Clears all the rendered data.voidClear all selected objects.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 (-1 if no one is selected).<T> Set<T>Returns the selected objects.static <D> IChosenboxController<D>of(IChosenbox owner, ListModel<D> model) Returns the controller instance with the givenchosenboxstatic <D> IChosenboxController<D>of(IChosenbox owner, ListModel<D> model, CheckedFunction2<D, Integer, String> renderer) Returns the controller instance with the givenchosenboxvoidRemove an item from selection.voidSets the given model to this controller.voidsetRenderer(CheckedFunction2<DataT, Integer, String> renderer) Sets the renderer which is used to render each data ifItemController.getModel()is not null.voidsetSelectedIndex(int jsel) Sets the index of the selected item (-1 if no one is selected).voidsetSelectedObjects(Collection<DataT> objects) Sets the selected objects.
-
Method Details
-
of
Returns the controller instance with the givenchosenbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the chosenbox.
-
of
public static <D> IChosenboxController<D> of(IChosenbox owner, ListModel<D> model, CheckedFunction2<D, Integer, String> renderer) Returns the controller instance with the givenchosenbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the chosenbox.
-
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,ListModel<DataT>, IChosenbox, String>
-
getModel
Description copied from interface:ItemControllerReturns the model, which is set through byItemController.setModel(Object), or null.- Specified by:
getModelin interfaceItemController<DataT,ListModel<DataT>, IChosenbox, 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,ListModel<DataT>, IChosenbox, 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,ListModel<DataT>, IChosenbox, String>
-
build
Description copied from interface:ItemControllerReturns the immutable instance that the controller to build with- Specified by:
buildin interfaceItemController<DataT,ListModel<DataT>, IChosenbox, String>
-
clear
public void clear()Description copied from interface:ItemControllerClears all the rendered data.- Specified by:
clearin interfaceItemController<DataT,ListModel<DataT>, IChosenbox, String>
-
getSelectedIndex
public int getSelectedIndex()Returns the index of the selected item (-1 if no one is selected). -
setSelectedIndex
public void setSelectedIndex(int jsel) Sets the index of the selected item (-1 if no one is selected). If model already exists, it will update the selection of model.- Parameters:
jsel- the index to select.
-
getSelectedObjects
Returns the selected objects. -
setSelectedObjects
Sets the selected objects.- Parameters:
objects- the objects to select.
-
clearSelection
public void clearSelection()Clear all selected objects. -
addItemToSelection
Add an item into selection.- Parameters:
o- the object to add.
-
removeItemFromSelection
Remove an item from selection.- Parameters:
o- the object to remove.
-