In my JSF 2.2, Primefaces 5.3 web-application, I want the user to visit a view with predefined filter state (e.g. depending on his user account)
To achieve this, I tried to programmatically apply a filter to a dataTable (i.e. from the backing bean).
In my backing bean I tried:
@ManagedBean
@ViewScoped
public class MyCointroller
private DataTable dataTable = new DataTable();
@PostConstruct
public void init() {
Map<String, Object> myFilter = new HashMap<String, Object>();
myFilter.put("userName", "Peter");
dataTable.setFilters(myFilter);
}
Where I use "binding" with the dataTable in my facelet.
<p:dataTable var=user"
value="#{myController.users}"
binding="#{myController.dataTable}">
<p:column headerText="Bezeichnung"
filterMatchMode="contains" filterBy="#{user.name}">
<h:outputText value="#{user.name}" />
</p:column>
The binding itself works, I can read the applied filters from my backing bean, but I fail to apply myFilter
to the dataTable (the table doesn't get filtered in the view).
myController.user
? – Johnny Willer