Package org.zkoss.stateless.state
Class ISearchboxController<DataT>
java.lang.Object
org.zkoss.stateless.state.ISearchboxController<DataT>
- All Implemented Interfaces:
ItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISearchbox, String>
public class ISearchboxController<DataT>
extends Object
implements ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ISearchbox,String>
An
ISearchbox 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 number of items being selected.Returns the selected item, or null if no item is selected.<T> Set<T>Returns the selected objects.booleanReturns whether multiple selections are allowed.static <D> ISearchboxController<D>of(ISearchbox owner, org.zkoss.zul.ListModel<D> model) Returns the controller instance with the givensearchboxstatic <D> ISearchboxController<D>of(ISearchbox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<Object, Integer, String> renderer) Returns the controller instance with the givensearchboxvoidsetItemConverter(org.zkoss.util.Converter<Collection<DataT>, String> converter) Sets the converter that generates the label text shown in the searchbox from selected items.voidSets 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.voidsetSelectedObject(DataT item) Deselects all the currently selected items and selects the given item.voidsetSelectedObjects(Collection<DataT> selectedItems) Selects the given items.
-
Method Details
-
of
Returns the controller instance with the givensearchbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the searchbox.
-
of
public static <D> ISearchboxController<D> of(ISearchbox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<Object, Integer, String> renderer) Returns the controller instance with the givensearchbox- Parameters:
owner- The controller to control withmodel- The list model to associate with the searchbox.renderer- The renderer of the list model.
-
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>, ISearchbox, 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>, ISearchbox, 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>, ISearchbox, 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>, ISearchbox, String>
-
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>, ISearchbox, String>
-
clear
public void clear()Description copied from interface:ItemControllerClears all the rendered data.- Specified by:
clearin interfaceItemController<DataT,org.zkoss.zul.ListModel<DataT>, ISearchbox, String>
-
setItemConverter
Sets the converter that generates the label text shown in the searchbox from selected items.- Parameters:
converter- the converter, or null to use the default implementation.
-
isMultiple
public boolean isMultiple()Returns whether multiple selections are allowed.Default:
false. -
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)). -
setSelectedObjects
Selects the given items. Must be non-null values. -
getSelectedObjects
Returns the selected objects. -
getSelectedObject
Returns the selected item, or null if no item is selected. -
setSelectedObject
Deselects all the currently selected items and selects the given item. -
getSelectedCount
public int getSelectedCount()Returns the number of items being selected. -
clearSelection
public void clearSelection()Clears the selection.
-