Datatable - Using FilterFeature changes value type
Posted: 02 Jun 2023, 17:07
Hi all,
We have a strange behavior with the datatable & filters, we are using internaly a custom ListModel with some additional data.
If we load our datatable and select lines, sort columns, no issues at all.
But when we first do a filter on one column, the value type of the datatable is modified and is never restored.
As far as i can see it seems related to the FilterFeature that calls setValue with an ArrayList type instead of the original model.
End of FilterFeature.filter():
I reproduce the case easily with a simple test, using a basic datatable with one colum with sort and filter, and a simple dataModel.
DataModel:
Page: (Binding is just used here to display easily the value type inside the component)
So with sorting or even selecting lines, no changes on the value type.
But when filter is used the first time we can see using the binding attribute that the value type as changed.
Logs showing the value type, on page first load, then on sort, and finaly after a filter:
Also note, that we were using Primefaces 6.1 previously and the value type was still ok after filtering.
Wish the use case is clear,
Thanks
We have a strange behavior with the datatable & filters, we are using internaly a custom ListModel with some additional data.
If we load our datatable and select lines, sort columns, no issues at all.
But when we first do a filter on one column, the value type of the datatable is modified and is never restored.
As far as i can see it seems related to the FilterFeature that calls setValue with an ArrayList type instead of the original model.
End of FilterFeature.filter():
Code: Select all
//save filtered data
table.setFilteredValue(filtered);
table.setValue(filtered);
table.setRowIndex(-1); //reset datamodel
DataModel:
Code: Select all
public class TableModel<E>
extends
ListDataModel<E>
implements
Serializable
{
public TableModel(List<E> datasource)
{
super(datasource);
}
}
Code: Select all
<p:dataTable id="cars" var="car"
value="#{tableController.dataModelSingle}"
rowKey="#{car.model}" sortBy="#{car.manufacturer}"
binding="#{tableController.table}"
widgetVar="carsEdition">
...
</dataTable >
But when filter is used the first time we can see using the binding attribute that the value type as changed.
Logs showing the value type, on page first load, then on sort, and finaly after a filter:
Code: Select all
16:37:10,379 ERROR [stderr] class com.test.TableModel
16:37:13,940 ERROR [stderr] class com.test.TableModel
16:37:19,922 ERROR [stderr] class java.util.ArrayList
Wish the use case is clear,
Thanks