Package org.zkoss.stateless.state
Class ISearchboxController<Data>
- java.lang.Object
-
- org.zkoss.stateless.state.ISearchboxController<Data>
-
- All Implemented Interfaces:
ItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
public class ISearchboxController<Data> extends java.lang.Object implements ItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
AnISearchbox
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 ISearchbox
build()
Returns the immutable instance that the controller to build withvoid
clear()
Clears all the rendered data.void
clearSelection()
Clears the selection.ListModel<Data>
getModel()
Returns the model, which is set through byItemController.setModel(Object)
, or null.CheckedFunction2<Data,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.int
getSelectedCount()
Returns the number of items being selected.Data
getSelectedObject()
Returns the selected item, or null if no item is selected.<T> java.util.Set<T>
getSelectedObjects()
Returns the selected objects.boolean
isMultiple()
Returns whether multiple selections are allowed.static <D> ISearchboxController<D>
of(ISearchbox owner, ListModel<D> model)
Returns the controller instance with the givensearchbox
static <D> ISearchboxController<D>
of(ISearchbox owner, ListModel<D> model, CheckedFunction2<java.lang.Object,java.lang.Integer,java.lang.String> renderer)
Returns the controller instance with the givensearchbox
void
setItemConverter(Converter<java.util.Collection<Data>,java.lang.String> converter)
Sets the converter that generates the label text shown in the searchbox from selected items.void
setModel(ListModel<Data> model)
Sets the given model to this controller.void
setMultiple(boolean multiple)
Sets whether multiple selections are allowed.void
setRenderer(CheckedFunction2<Data,java.lang.Integer,java.lang.String> renderer)
Sets the renderer which is used to render each data ifItemController.getModel()
is not null.void
setSelectedObject(Data item)
Deselects all the currently selected items and selects the given item.void
setSelectedObjects(java.util.Collection<Data> selectedItems)
Selects the given items.
-
-
-
Method Detail
-
of
public static <D> ISearchboxController<D> of(ISearchbox owner, ListModel<D> model)
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, ListModel<D> model, CheckedFunction2<java.lang.Object,java.lang.Integer,java.lang.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
public void setModel(ListModel<Data> model)
Description copied from interface:ItemController
Sets 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:
setModel
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
getModel
public ListModel<Data> getModel()
Description copied from interface:ItemController
Returns the model, which is set through byItemController.setModel(Object)
, or null.- Specified by:
getModel
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
setRenderer
public void setRenderer(CheckedFunction2<Data,java.lang.Integer,java.lang.String> renderer)
Description copied from interface:ItemController
Sets 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:
setRenderer
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
getRenderer
public CheckedFunction2<Data,java.lang.Integer,java.lang.String> getRenderer()
Description copied from interface:ItemController
Returns the renderer, which is set through byItemController.setRenderer(CheckedFunction2)
, or a default one which is depended on implementation.- Specified by:
getRenderer
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
build
public ISearchbox build()
Description copied from interface:ItemController
Returns the immutable instance that the controller to build with- Specified by:
build
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
clear
public void clear()
Description copied from interface:ItemController
Clears all the rendered data.- Specified by:
clear
in interfaceItemController<Data,ListModel<Data>,ISearchbox,java.lang.String>
-
setItemConverter
public void setItemConverter(Converter<java.util.Collection<Data>,java.lang.String> converter)
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
public void setSelectedObjects(java.util.Collection<Data> selectedItems)
Selects the given items. Must be non-null values.
-
getSelectedObjects
public <T> java.util.Set<T> getSelectedObjects()
Returns the selected objects.
-
getSelectedObject
public Data getSelectedObject()
Returns the selected item, or null if no item is selected.
-
setSelectedObject
public void setSelectedObject(Data item)
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.
-
-