Package org.zkoss.stateless.state

## Class IListboxController<DataT,​RowT extends IListitemBase>

- java.lang.Object
- - org.zkoss.stateless.state.IListboxController<DataT,​RowT>

- All Implemented Interfaces:
    `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT>`

      public class IListboxController<DataT,​RowT extends IListitemBase>
      extends java.lang.Object
      implements ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT>

  An `IListbox` 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:
    jumperchen

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `IListboxController.DataLoadingData` |
    `protected static class` | `IListboxController.DeferredRedraw` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `IListbox` | `build()` | Returns the immutable instance that the controller to build with
    `void` | `clear()` | Clears all the rendered data.
    `void` | `doAnchorPos​(RequestData requestData)` |
    `void` | `doPaging​(PagingData pagingData)` |
    `void` | `doScrollPos​(RequestData requestData)` |
    `void` | `doSelect​(RequestData requestData)` |
    `void` | `doSort​(SortData sortData)` |
    `void` | `doTopPad​(RequestData requestData)` |
    `CheckedFunction3<DataT,​java.lang.Integer,​GroupingInfo,​RowT>` | `getGroupsRenderer()` | Returns the groups renderer.
    `ListModel<DataT>` | `getModel()` | Returns the model, which is set through by `ItemController.setModel(Object)`, or null.
    `CheckedFunction2<DataT,​java.lang.Integer,​RowT>` | `getRenderer()` | Returns the renderer, which is set through by `ItemController.setRenderer(CheckedFunction2)`, or a default one which is depended on implementation.
    `int` | `getSelectedIndex()` | Returns the index of the selected item, or -1 if not selected.
    `DataT` | `getSelectedObject()` | Returns the data object which is selected or null.
    `static <D,​G,​F,​R extends IListitemBase> IListboxController<D,​R>` | `of​(IListbox owner, GroupsModel<D,​G,​F> model)` | Returns the controller instance with the given `listbox`
    `static <D,​G,​F,​R extends IListitemBase> IListboxController<D,​R>` | `of​(IListbox owner, GroupsModel<D,​G,​F> model, CheckedFunction2<D,​java.lang.Integer,​R> renderer)` | Returns the controller instance with the given `listbox`
    `static <D,​R extends IListitemBase> IListboxController<D,​R>` | `of​(IListbox owner, ListModel<D> model)` | Returns the controller instance with the given `listbox`
    `static <D,​R extends IListitemBase> IListboxController<D,​R>` | `of​(IListbox owner, ListModel<D> model, CheckedFunction2<D,​java.lang.Integer,​R> renderer)` | Returns the controller instance with the given `listbox`
    `void` | `onAfterRender()` |
    `void` | `setGroupsRenderer​(CheckedFunction3<DataT,​java.lang.Integer,​GroupingInfo,​RowT> renderer)` | Sets the groups renderer for `GroupsModel`
    `void` | `setModel​(GroupsModel<?,​?,​?> model)` | Sets the groups model for this controller to render.
    `void` | `setModel​(ListModel<DataT> model)` | Sets the given model to this controller.
    `void` | `setRenderer​(CheckedFunction2<DataT,​java.lang.Integer,​RowT> renderer)` | Sets the renderer which is used to render each data if `ItemController.getModel()` is not null.
    `void` | `setSelectedIndex​(int index)` | Deselects the currently selected items and selects the item with the given index.
    `void` | `setSelectedObject​(DataT data)` | Sets the selected data object, or deselects it by passing a null value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### of

          public static <D,​R extends IListitemBase> IListboxController<D,​R> of​(IListbox owner,
                                                                                           ListModel<D> model)

      Returns the controller instance with the given `listbox`
      Parameters:
        `owner` - The controller to control with
        `model` - The list model to associate with the listbox.

    - #### of

          public static <D,​R extends IListitemBase> IListboxController<D,​R> of​(IListbox owner,
                                                                                           ListModel<D> model,
                                                                                           CheckedFunction2<D,​java.lang.Integer,​R> renderer)

      Returns the controller instance with the given `listbox`
      Parameters:
        `owner` - The controller to control with
        `model` - The list model to associate with the listbox.
        `renderer` - The renderer of the list model.

    - #### of

          public static <D,​G,​F,​R extends IListitemBase> IListboxController<D,​R> of​(IListbox owner,
                                                                                                           GroupsModel<D,​G,​F> model)

      Returns the controller instance with the given `listbox`
      Parameters:
        `owner` - The controller to control with
        `model` - The groups model to associate with the listbox.

    - #### of

          public static <D,​G,​F,​R extends IListitemBase> IListboxController<D,​R> of​(IListbox owner,
                                                                                                           GroupsModel<D,​G,​F> model,
                                                                                                           CheckedFunction2<D,​java.lang.Integer,​R> renderer)

      Returns the controller instance with the given `listbox`
      Parameters:
        `owner` - The controller to control with
        `model` - The groups model to associate with the listbox.
        `renderer` - The renderer of the groups model.

    - #### setModel

          public void setModel​(GroupsModel<?,​?,​?> model)

      Sets the groups model for this controller to render.
      Parameters:
        `model` - The groups model.

    - #### setModel

          public void setModel​(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,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### getModel

          public ListModel<DataT> getModel()

      Description copied from interface: `ItemController`
      Returns the model, which is set through by `ItemController.setModel(Object)`, or null.
      Specified by:
        `getModel` in interface `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### setRenderer

          public void setRenderer​(CheckedFunction2<DataT,​java.lang.Integer,​RowT> renderer)

      Description copied from interface: `ItemController`
      Sets the renderer which is used to render each data if `ItemController.getModel()` is not null.

      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`, or depended on the implementation

      Specified by:
        `setRenderer` in interface `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### setGroupsRenderer

          public void setGroupsRenderer​(CheckedFunction3<DataT,​java.lang.Integer,​GroupingInfo,​RowT> renderer)

      Sets the groups renderer for `GroupsModel`
      Parameters:
        `renderer` - The renderer for GroupsModel.

    - #### clear

          public void clear()

      Description copied from interface: `ItemController`
      Clears all the rendered data.
      Specified by:
        `clear` in interface `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### getRenderer

          public CheckedFunction2<DataT,​java.lang.Integer,​RowT> getRenderer()

      Description copied from interface: `ItemController`
      Returns the renderer, which is set through by `ItemController.setRenderer(CheckedFunction2)`, or a default one which is depended on implementation.
      Specified by:
        `getRenderer` in interface `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### getGroupsRenderer

          public CheckedFunction3<DataT,​java.lang.Integer,​GroupingInfo,​RowT> getGroupsRenderer()

      Returns the groups renderer.

      Default: `null`

    - #### build

          public IListbox build()

      Description copied from interface: `ItemController`
      Returns the immutable instance that the controller to build with
      Specified by:
        `build` in interface `ItemController<DataT,​ListModel<DataT>,​IListbox,​RowT extends IListitemBase>`

    - #### onAfterRender

          public void onAfterRender()

    - #### doTopPad

          public void doTopPad​(RequestData requestData)

    - #### doScrollPos

          public void doScrollPos​(RequestData requestData)

    - #### doAnchorPos

          public void doAnchorPos​(RequestData requestData)

    - #### doSelect

          public void doSelect​(RequestData requestData)

    - #### doSort

          public void doSort​(SortData sortData)

    - #### doPaging

          public void doPaging​(PagingData pagingData)

    - #### 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.