Class DataTableManager<T>

java.lang.Object
fr.paris.lutece.util.datatable.DataTableManager<T>
Type Parameters:
T - Type of data to display
All Implemented Interfaces:
Serializable

public class DataTableManager<T> extends Object implements Serializable
Class to manage data tables with freemarker macros
See Also:
  • Constructor Details

    • DataTableManager

      public DataTableManager(String strSortUrl, String strFilterUrl, int nDefautlItemsPerPage, boolean bEnablePaginator)
      Constructor of the DataTableManager class
      Parameters:
      strSortUrl - URL used by the paginator to sort data
      strFilterUrl - URL used to filter data
      nDefautlItemsPerPage - Default number of items to display per page
      bEnablePaginator - True to enable pagination, false to disable it
  • Method Details

    • addColumn

      public void addColumn(String strColumnTitle, String strObjectName, boolean bSortable)
      Add a column to this DataTableManager
      Parameters:
      strColumnTitle - I18n key of the title of the column
      strObjectName - Name of the property of objects that should be displayed in this column.
      For example, if a class "Data" contains a property named "title", then the value of the parameter strObjectName should be "title".
      bSortable - True if the column is sortable, false otherwise
    • addLabelColumn

      public void addLabelColumn(String strColumnTitle, String strObjectName, boolean bSortable)
      Add a label column to this DataTableManager. Values of cells of this column will be interpreted as i18n keys.
      Parameters:
      strColumnTitle - I18n key of the title of the column
      strObjectName - Name of the property of objects that should be displayed in this column. This properties must be i18n keys.
      For example, if a class "Data" contains a property named "title", then the value of the parameter strObjectName should be "title".
      bSortable - True if the column is sortable, false otherwise
    • addActionColumn

      public void addActionColumn(String strColumnTitle)
      Add an column to this DataTableManager that will display actions on items. Actions are usually parameterized links. A DataTableManager can only have 1 action column. The content of the action column must be generated by a macro.this macro must have one parameter named "item", and its name must be given to the macro @tableData.
      Parameters:
      strColumnTitle - I18n key of the title of the column
    • addBooleanColumn

      public void addBooleanColumn(String strColumnTitle, String strObjectName, String strLabelTrue, String strLabelFalse)
      Add a column to this DataTableManager
      Parameters:
      strColumnTitle - I18n key of the title of the column
      strObjectName - Name of the property of objects that should be displayed in this column.
      For example, if a class "Data" contains a property named "title", then the value of the parameter strObjectName should be "title".
      strLabelTrue - I18n key of the label to display when the value is true
      strLabelFalse - I18n key of the label to display when the value is false
    • addFreeColumn

      public void addFreeColumn(String strColumnTitle, String strFreemarkerMacroName)
      Add a free column to this DataTableManager. The content of this column must be generated by a macro. The macro must have one parameter named "item".
      Parameters:
      strColumnTitle - I18n key of the title of the column
      strFreemarkerMacroName - Name of the freemarker macro that will display the content of the column.
      The macro must have a single parameter named item of type T that will contain the object associated with a row of the table.
    • addEmailColumn

      public void addEmailColumn(String strColumnTitle, String strObjectName, boolean bSortable)
      Add an email column to this DataTableManager. Displayed cell will be a "mailto:" link.
      Parameters:
      strColumnTitle - I18n key of the title of the column
      strObjectName - Name of the property of objects that should be displayed in this column.
      For example, if a class "Data" contains a property named "title", then the value of the parameter strObjectName should be "title".
      bSortable - True if the column is sortable, false otherwise
    • addFilter

      public void addFilter(DataTableFilterType filterType, String strParameterName, String strFilterLabel)
      Add a filter to the filter panel of this DataTableManager
      Parameters:
      filterType - data type of the filter. For drop down list, use addDropDownListFilter instead
      strParameterName - Name of the parameter of the object to filter.
      For example, if this filter should be applied on the parameter "title" of a class named "Data", then the value of the parameter strParameterName should be "title".
      strFilterLabel - Label describing the filter
    • addDropDownListFilter

      public void addDropDownListFilter(String strParameterName, String strFilterLabel, ReferenceList refList)
      Add a drop down list filter to the filter panel of this DataTableManager
      Parameters:
      strParameterName - Name of the parameter of the object to filter.
      For example, if this filter should be applied on the parameter "title" of a class named "Data", then the value of the parameter strParameterName should be "title".
      strFilterLabel - Label describing the filter
      refList - Reference list containing data of the drop down list
    • filterSortAndPaginate

      public void filterSortAndPaginate(javax.servlet.http.HttpServletRequest request, List<T> items)
      Apply filters on an objects list, sort it and update pagination values.
      Parameters:
      request - The request
      items - Collection of objects to filter, sort and paginate
    • getFilterPanel

      public FilterPanel getFilterPanel()
      Get the filter panel of the DataTableManager
      Returns:
      The filter panel of the DataTableManager
    • setFilterPanel

      public void setFilterPanel(FilterPanel filterPanel)
      Set the filter panel of the DataTableManager
      Parameters:
      filterPanel - Filter panel
    • getListColumn

      public List<DataTableColumn> getListColumn()
      Get the list of columns of this DataTableManager
      Returns:
      The list of columns of this DataTableManager
    • setListColumn

      public void setListColumn(List<DataTableColumn> listColumn)
      Set the list of columns of this DataTableManager
      Parameters:
      listColumn - The list of columns of this DataTableManager
    • getSortUrl

      public String getSortUrl()
      Get the sort url of this DataTableManager
      Returns:
      The sort url of this DataTableManager
    • setSortUrl

      public void setSortUrl(String strSortUrl)
      Set the sort url of this DataTableManager
      Parameters:
      strSortUrl - The sort url of this DataTableManager
    • getItems

      public List<T> getItems()
      Get the filtered, sorted and paginated items collection of this DataTableManager
      Returns:
      The filtered, sorted and paginated items collection of this DataTableManager
    • setItems

      public void setItems(List<T> items, int nTotalItemsNumber)
      Set the items to display. The list of items must be fintered, sorted and paginated. Methods getAndUpdatePaginator, getAndUpdateSort and getAndUpdateFilter must have been called before the generation of the list of items.
      Parameters:
      items - The filtered sorted and paginated list of items to display
      nTotalItemsNumber - The total number of items
    • clearItems

      public void clearItems()
      Clear the items stored by this DataTableManager so that the garbage collector can free the memory they use.
    • getPaginator

      public IPaginator<T> getPaginator()
      Internal method. Get the paginator. Do not use this method, use getAndUpdatePaginator instead to get up to date values !
      Returns:
      The paginator
    • getEnablePaginator

      public boolean getEnablePaginator()
      Get the enable paginator boolean
      Returns:
      True if pagination is active, false otherwise
    • getLocale

      public Locale getLocale()
      Get the locale
      Returns:
      The locale
    • setLocale

      public void setLocale(Locale locale)
      Set the locale
      Parameters:
      locale - The locale
    • getId

      public String getId()
      Get the unique id of this data table manager
      Returns:
      The unique id of this data table manager
    • getAndUpdatePaginator

      public DataTablePaginationProperties getAndUpdatePaginator(javax.servlet.http.HttpServletRequest request)
      Get the paginator updated with values in the request
      Parameters:
      request - The request
      Returns:
      The paginator up to date
    • getAndUpdateSort

      public DataTableSort getAndUpdateSort(javax.servlet.http.HttpServletRequest request)
      Get sort properties updated with values in the request
      Parameters:
      request - The request
      Returns:
      The sort properties up to date
    • getAndUpdateFilter

      public <K> K getAndUpdateFilter(javax.servlet.http.HttpServletRequest request, K filterObject)
      Get filter properties updated with values in the request
      Type Parameters:
      K - Type of the filter to use. This type must have accessors for every declared filter.
      Parameters:
      request - The request
      filterObject - Filter to apply.
      Returns:
      The filter properties up to date
    • getFilterPanelPrefix

      public String getFilterPanelPrefix()
      Internal method. Get the prefix of html attributes used by filters
      Returns:
      The prefix of html attributes used by filters