Class DaoLazyDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>

  • Type Parameters:
    T - Type of the entities to store in the lazy list model.
    All Implemented Interfaces:
    Serializable, Iterable<T>, org.primefaces.model.SelectableDataModel<T>

    public class DaoLazyDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    extends org.primefaces.model.LazyDataModel<T>
    LazyDataModel for IEntitys & use with DataTable. Helps defining SortingCriterion as well as FilterCriterion.
    Since:
    8.0.0
    See Also:
    Serialized Form
    • Method Detail

      • builder

        public static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> DaoLazyDataModel.Builder<T> builder​(EEntityKeySelectionType keyType,
                                                                                                               Class<T> entityClass)
        Creates a new builder for a lazy entity list model.
        Type Parameters:
        T - Type of the entity to store in the lazy list model.
        Parameters:
        keyType - Scope of the entity that determines how the currently selected entity is stored. Used to restore the last selected entity when the UI is reloaded.
        entityClass - Type of the entity.
        Returns:
        A new builder for configuring a lazy entity list model.
      • load

        public List<T> load​(int first,
                            int pageSize,
                            Map<String,​org.primefaces.model.SortMeta> sortBy,
                            Map<String,​org.primefaces.model.FilterMeta> filterBy)
        Specified by:
        load in class org.primefaces.model.LazyDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
      • count

        public int count​(Map<String,​org.primefaces.model.FilterMeta> filterBy)
        Specified by:
        count in class org.primefaces.model.LazyDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
      • getRowKey

        public String getRowKey​(T entity)
        Specified by:
        getRowKey in interface org.primefaces.model.SelectableDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
        Overrides:
        getRowKey in class org.primefaces.model.LazyDataModel<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
      • getSelected

        public T getSelected()
        Returns:
        The currently selected entity.
      • setSelected

        public void setSelected​(T selected)
        Parameters:
        selected - The entity to select.
      • getMarked

        public List<T> getMarked()
      • setMarked

        public void setMarked​(List<T> marked)
      • setFirst

        public void setFirst​(int first)
        Parameters:
        first - The index of the first item of the page to display.
      • getFirst

        public int getFirst()
        Returns:
        The index of the first item of the page to display.
      • selectFirstOfPage

        public void selectFirstOfPage()
        Selects the first item on the current page, if such an item exists.
      • moveToPageOfSelected

        public void moveToPageOfSelected()
        Switches to the page that contains the currently selected item.
      • restoreSavedSelection

        public void restoreSavedSelection()
        Reads the last selected entity, and, if such an entity exists, selects that entity. This should usually be called only once for a given UI page, after the model was created.