Package org.zkoss.stateless.state
Class IChosenboxController<DataT>
- java.lang.Object
-
- org.zkoss.stateless.state.IChosenboxController<DataT>
-
- All Implemented Interfaces:
ItemController<DataT,org.zkoss.zul.ListModel<DataT>,IChosenbox,java.lang.String>
public class IChosenboxController<DataT> extends java.lang.Object implements ItemController<DataT,org.zkoss.zul.ListModel<DataT>,IChosenbox,java.lang.String>
AnIChosenboxcontroller 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 voidaddItemToSelection(java.lang.Object o)Add an item into selection.IChosenboxbuild()Returns the immutable instance that the controller to build withvoidclear()Clears all the rendered data.voidclearSelection()Clear all selected objects.org.zkoss.zul.ListModel<DataT>getModel()Returns the model, which is set through byItemController.setModel(Object), or null.CheckedFunction2<DataT,java.lang.Integer,java.lang.String>getRenderer()Returns the renderer, which is set through byItemController.setRenderer(CheckedFunction2), or a default one which is depended on implementation.intgetSelectedIndex()Returns the index of the selected item (-1 if no one is selected).<T> java.util.Set<T>getSelectedObjects()Returns the selected objects.static <D> IChosenboxController<D>of(IChosenbox owner, org.zkoss.zul.ListModel<D> model)Returns the controller instance with the givenchosenboxstatic <D> IChosenboxController<D>of(IChosenbox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D,java.lang.Integer,java.lang.String> renderer)Returns the controller instance with the givenchosenboxvoidremoveItemFromSelection(java.lang.Object o)Remove an item from selection.voidsetModel(org.zkoss.zul.ListModel<DataT> model)Sets the given model to this controller.voidsetRenderer(CheckedFunction2<DataT,java.lang.Integer,java.lang.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(java.util.Collection<DataT> objects)Sets the selected objects.
-
-
-
Method Detail
-
of
public static <D> IChosenboxController<D> of(IChosenbox owner, org.zkoss.zul.ListModel<D> model)
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, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D,java.lang.Integer,java.lang.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
public void setModel(org.zkoss.zul.ListModel<DataT> model)
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>,IChosenbox,java.lang.String>
-
getModel
public org.zkoss.zul.ListModel<DataT> 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>,IChosenbox,java.lang.String>
-
setRenderer
public void setRenderer(CheckedFunction2<DataT,java.lang.Integer,java.lang.String> renderer)
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>,IChosenbox,java.lang.String>
-
getRenderer
public CheckedFunction2<DataT,java.lang.Integer,java.lang.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>,IChosenbox,java.lang.String>
-
build
public IChosenbox 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>,IChosenbox,java.lang.String>
-
clear
public void clear()
Description copied from interface:ItemControllerClears all the rendered data.- Specified by:
clearin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>,IChosenbox,java.lang.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
public <T> java.util.Set<T> getSelectedObjects()
Returns the selected objects.
-
setSelectedObjects
public void setSelectedObjects(java.util.Collection<DataT> objects)
Sets the selected objects.- Parameters:
objects- the objects to select.
-
clearSelection
public void clearSelection()
Clear all selected objects.
-
addItemToSelection
public void addItemToSelection(java.lang.Object o)
Add an item into selection.- Parameters:
o- the object to add.
-
removeItemFromSelection
public void removeItemFromSelection(java.lang.Object o)
Remove an item from selection.- Parameters:
o- the object to remove.
-
-