Class IComboboxController<DataT>

java.lang.Object
org.zkoss.stateless.state.IComboboxController<DataT>
All Implemented Interfaces:
ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>

public class IComboboxController<DataT> extends Object implements ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
An ICombobox 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 Details

    • of

      public static <D> IComboboxController<D> of(ICombobox owner, org.zkoss.zul.ListModel<D> model)
      Returns the controller instance with the given combobox, and ListModel.
      Parameters:
      owner - The controller to control with
      model - The data model for the combobox.
    • of

      public static <D> IComboboxController<D> of(ICombobox owner, org.zkoss.zul.ListModel<D> model, CheckedFunction2<D,Integer,IComboitem> renderer)
      Returns the controller instance with the given combobox, ListModel, and CheckedFunction2<D,Integer,IComboitem>
      Parameters:
      owner - The controller to control with
      model - The data model for the combobox.
      renderer - The data renderer for the combobox.
    • setModel

      public void setModel(org.zkoss.zul.ListModel<DataT> model)
      Sets the list model associated with this combobox. If a non-null model is assigned, no matter whether it is the same as the previous, it will always cause re-render.
      Specified by:
      setModel in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
      Parameters:
      model - the list model to associate, or null to dissociate any previous model.
      Throws:
      org.zkoss.zk.ui.UiException - if failed to initialize with the model
    • setInvalidateThreshold

      public void setInvalidateThreshold(int invalidateThreshold)
      Sets the threshold number of changed items of a model to invalidate a widget's DOM elements

      Default: 10

      Parameters:
      invalidateThreshold - The threshold number
    • getModel

      public org.zkoss.zul.ListModel<DataT> getModel()
      Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model.
      Specified by:
      getModel in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
    • setRenderer

      public void setRenderer(CheckedFunction2<DataT,Integer,IComboitem> renderer)
      Sets the renderer which is used to render each row if getModel() is not null.

      Note: changing a render will not cause the combobox to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(getModel())), or fire an ListDataEvent event.

      Specified by:
      setRenderer in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
      Parameters:
      renderer - the renderer, or null to use the default.
    • getRenderer

      public CheckedFunction2<DataT,Integer,IComboitem> getRenderer()
      Returns the renderer to render each row, or null if the default renderer is used.
      Specified by:
      getRenderer in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
    • build

      public ICombobox build()
      Returns the immutable combobox instance that the controller to build with.
      Specified by:
      build in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
    • clear

      public void clear()
      Description copied from interface: ItemController
      Clears all the rendered data.
      Specified by:
      clear in interface ItemController<DataT,org.zkoss.zul.ListModel<DataT>,ICombobox,IComboitem>
    • getSelectedObject

      public DataT getSelectedObject()
      Returns the data object which is selected or null.

      Default: null

    • setSelectedObject

      public void setSelectedObject(DataT data)
      Sets the selected data object, or deselects it by passing a null value.
      Parameters:
      data - The data object that contains in the model.
    • getSelectedIndex

      public int getSelectedIndex()
      Returns the index of the selected item, or -1 if not selected.
    • setSelectedIndex

      public void setSelectedIndex(int index)
      Deselects the currently selected items and selects the item with the given index.

      Note: if the data has the same more than one, the first data item will be selected at client side, it is a limitation of ICombobox and it is different from IListbox.