Class 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>
    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 Detail

      • of

        public static <D> IChosenboxController<D> of​(IChosenbox owner,
                                                     org.zkoss.zul.ListModel<D> model)
        Returns the controller instance with the given chosenbox
        Parameters:
        owner - The controller to control with
        model - 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 given chosenbox
        Parameters:
        owner - The controller to control with
        model - The list model to associate with the chosenbox.
      • setModel

        public void setModel​(org.zkoss.zul.ListModel<DataT> model)
        Description copied from interface: ItemController
        Sets the given model to this controller.

        Note: calling this method after ItemController.build(), you should invoke ItemController.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 interface ItemController<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.