Package fr.paris.lutece.util.datatable
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
Class to manage data tables with freemarker macros
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDataTableManager(String strSortUrl, String strFilterUrl, int nDefautlItemsPerPage, boolean bEnablePaginator) Constructor of the DataTableManager class -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionColumn(String strColumnTitle) Add an column to this DataTableManager that will display actions on items.voidaddBooleanColumn(String strColumnTitle, String strObjectName, String strLabelTrue, String strLabelFalse) Add a column to this DataTableManagervoidAdd a column to this DataTableManagervoidaddDropDownListFilter(String strParameterName, String strFilterLabel, ReferenceList refList) Add a drop down list filter to the filter panel of this DataTableManagervoidaddEmailColumn(String strColumnTitle, String strObjectName, boolean bSortable) Add an email column to this DataTableManager.voidaddFilter(DataTableFilterType filterType, String strParameterName, String strFilterLabel) Add a filter to the filter panel of this DataTableManagervoidaddFreeColumn(String strColumnTitle, String strFreemarkerMacroName) Add a free column to this DataTableManager.voidaddLabelColumn(String strColumnTitle, String strObjectName, boolean bSortable) Add a label column to this DataTableManager.voidClear the items stored by this DataTableManager so that the garbage collector can free the memory they use.voidfilterSortAndPaginate(javax.servlet.http.HttpServletRequest request, List<T> items) Apply filters on an objects list, sort it and update pagination values.<K> KgetAndUpdateFilter(javax.servlet.http.HttpServletRequest request, K filterObject) Get filter properties updated with values in the requestgetAndUpdatePaginator(javax.servlet.http.HttpServletRequest request) Get the paginator updated with values in the requestgetAndUpdateSort(javax.servlet.http.HttpServletRequest request) Get sort properties updated with values in the requestbooleanGet the enable paginator booleanGet the filter panel of the DataTableManagerInternal method.getId()Get the unique id of this data table managergetItems()Get the filtered, sorted and paginated items collection of this DataTableManagerGet the list of columns of this DataTableManagerGet the localeInternal method.Get the sort url of this DataTableManagervoidsetFilterPanel(FilterPanel filterPanel) Set the filter panel of the DataTableManagervoidSet the items to display.voidsetListColumn(List<DataTableColumn> listColumn) Set the list of columns of this DataTableManagervoidSet the localevoidsetSortUrl(String strSortUrl) Set the sort url of this DataTableManager
-
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 datastrFilterUrl- URL used to filter datanDefautlItemsPerPage- Default number of items to display per pagebEnablePaginator- True to enable pagination, false to disable it
-
-
Method Details
-
addColumn
Add a column to this DataTableManager- Parameters:
strColumnTitle- I18n key of the title of the columnstrObjectName- 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
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 columnstrObjectName- 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
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 columnstrObjectName- 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 truestrLabelFalse- I18n key of the label to display when the value is false
-
addFreeColumn
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 columnstrFreemarkerMacroName- 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
Add an email column to this DataTableManager. Displayed cell will be a "mailto:" link.- Parameters:
strColumnTitle- I18n key of the title of the columnstrObjectName- 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, useaddDropDownListFilterinsteadstrParameterName- 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 filterrefList- Reference list containing data of the drop down list
-
filterSortAndPaginate
Apply filters on an objects list, sort it and update pagination values.- Parameters:
request- The requestitems- Collection of objects to filter, sort and paginate
-
getFilterPanel
Get the filter panel of the DataTableManager- Returns:
- The filter panel of the DataTableManager
-
setFilterPanel
Set the filter panel of the DataTableManager- Parameters:
filterPanel- Filter panel
-
getListColumn
Get the list of columns of this DataTableManager- Returns:
- The list of columns of this DataTableManager
-
setListColumn
Set the list of columns of this DataTableManager- Parameters:
listColumn- The list of columns of this DataTableManager
-
getSortUrl
Get the sort url of this DataTableManager- Returns:
- The sort url of this DataTableManager
-
setSortUrl
Set the sort url of this DataTableManager- Parameters:
strSortUrl- The sort url of this DataTableManager
-
getItems
Get the filtered, sorted and paginated items collection of this DataTableManager- Returns:
- The filtered, sorted and paginated items collection of this DataTableManager
-
setItems
Set the items to display. The list of items must be fintered, sorted and paginated. MethodsgetAndUpdatePaginator,getAndUpdateSortandgetAndUpdateFiltermust have been called before the generation of the list of items.- Parameters:
items- The filtered sorted and paginated list of items to displaynTotalItemsNumber- 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
Internal method. Get the paginator. Do not use this method, usegetAndUpdatePaginatorinstead 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
Get the locale- Returns:
- The locale
-
setLocale
Set the locale- Parameters:
locale- The locale
-
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
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 requestfilterObject- Filter to apply.- Returns:
- The filter properties up to date
-
getFilterPanelPrefix
Internal method. Get the prefix of html attributes used by filters- Returns:
- The prefix of html attributes used by filters
-