Class SimpleListModel

java.lang.Object
org.zkoss.zul.AbstractListModel<Object>
org.adempiere.webui.component.SimpleListModel
All Implemented Interfaces:
Serializable, org.zkoss.zul.ext.Pageable, org.zkoss.zul.ext.Selectable<Object>, org.zkoss.zul.ext.Sortable<Object>, org.zkoss.zul.ListitemRenderer<Object>, org.zkoss.zul.ListitemRendererExt, org.zkoss.zul.ListModel<Object>, org.zkoss.zul.PageableModel

public class SimpleListModel extends org.zkoss.zul.AbstractListModel<Object> implements org.zkoss.zul.ListitemRenderer<Object>, org.zkoss.zul.ListitemRendererExt, org.zkoss.zul.ext.Sortable<Object>
List model for Listbox that also implements ListitemRenderer interface.
Author:
Low Heng Sin
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.zkoss.zul.AbstractListModel

    org.zkoss.zul.AbstractListModel.DefaultSelectionControl<E extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<Object>
    List backing this model instance

    Fields inherited from class org.zkoss.zul.AbstractListModel

    _selection

    Fields inherited from interface org.zkoss.zul.ListitemRendererExt

    DETACH_ON_RENDER

    Fields inherited from interface org.zkoss.zul.PageableModel

    INTERNAL_EVENT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
    Create model from list
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int index, Object obj)
    Add new row at index
    void
    Append new row
    int
     
    getElementAt(int index)
     
    int
     
     
    int
    indexOf(Object value)
     
    org.zkoss.zul.Listcell
    newListcell(org.zkoss.zul.Listitem item)
     
    org.zkoss.zul.Listitem
    newListitem(org.zkoss.zul.Listbox listbox)
     
    void
    Remove all elements
    void
    Remove element from list
    void
    render(org.zkoss.zul.Listitem item, Object data, int index)
     
    protected void
    renderCell(int col, org.zkoss.zul.Listitem item, String value)
    Render text Listbox cell/column
    void
    setElementAt(Object element, int index)
    Replace element at index
    void
    setMaxLength(int[] maxLength)
    Set max length for each column
    void
    sort(Comparator<Object> cmpr, boolean ascending)
     
    protected StringBuffer
    truncate(String src, int maxLength)
    Truncate src to maxLength.
    "..." will be added to the end of truncated text to indicate text have been truncated.

    Methods inherited from class org.zkoss.zul.AbstractListModel

    addListDataListener, addPagingEventListener, addToSelection, clearSelection, clone, fireEvent, fireSelectionEvent, getActivePage, getPageCount, getPageSize, getSelection, getSelectionControl, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelection

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.zkoss.zul.ext.Sortable

    sort
  • Field Details

    • list

      protected List<Object> list
      List backing this model instance
  • Constructor Details

    • SimpleListModel

      public SimpleListModel()
      Default constructor
    • SimpleListModel

      public SimpleListModel(List<?> list)
      Create model from list
      Parameters:
      list - List<?>
  • Method Details

    • getElementAt

      public Object getElementAt(int index)
      Specified by:
      getElementAt in interface org.zkoss.zul.ListModel<Object>
    • getSize

      public int getSize()
      Specified by:
      getSize in interface org.zkoss.zul.ListModel<Object>
    • truncate

      protected StringBuffer truncate(String src, int maxLength)
      Truncate src to maxLength.
      "..." will be added to the end of truncated text to indicate text have been truncated.
      Parameters:
      src - Input text
      maxLength - Maximum length of text
      Returns:
      truncated text
    • render

      public void render(org.zkoss.zul.Listitem item, Object data, int index) throws Exception
      Specified by:
      render in interface org.zkoss.zul.ListitemRenderer<Object>
      Throws:
      Exception
    • renderCell

      protected void renderCell(int col, org.zkoss.zul.Listitem item, String value)
      Render text Listbox cell/column
      Parameters:
      col - Column index
      item - Listitem
      value - Text content for cell
    • getControls

      public int getControls()
      Specified by:
      getControls in interface org.zkoss.zul.ListitemRendererExt
    • newListcell

      public org.zkoss.zul.Listcell newListcell(org.zkoss.zul.Listitem item)
      Specified by:
      newListcell in interface org.zkoss.zul.ListitemRendererExt
    • newListitem

      public org.zkoss.zul.Listitem newListitem(org.zkoss.zul.Listbox listbox)
      Specified by:
      newListitem in interface org.zkoss.zul.ListitemRendererExt
    • setMaxLength

      public void setMaxLength(int[] maxLength)
      Set max length for each column
      Parameters:
      maxLength - int[]
    • addElement

      public void addElement(Object obj)
      Append new row
      Parameters:
      obj - Object
    • add

      public void add(int index, Object obj)
      Add new row at index
      Parameters:
      index -
      obj - Object
    • removeAllElements

      public void removeAllElements()
      Remove all elements
    • removeElement

      public void removeElement(Object element)
      Remove element from list
      Parameters:
      element -
    • setElementAt

      public void setElementAt(Object element, int index)
      Replace element at index
      Parameters:
      element - Object
      index - List index
    • indexOf

      public int indexOf(Object value)
    • sort

      public void sort(Comparator<Object> cmpr, boolean ascending)
      Specified by:
      sort in interface org.zkoss.zul.ext.Sortable<Object>
    • getSortDirection

      public String getSortDirection(Comparator<Object> cmpr)
      Specified by:
      getSortDirection in interface org.zkoss.zul.ext.Sortable<Object>