问题
In my dataTable, I want to use selectCheckboxMenu
as a filter on one of columns (like in this example on Color column). My column looks like this:
<p:column filterBy="#{record.typeString}" filterMatchMode="in">
<f:facet name="filter">
<p:selectCheckboxMenu label="Types" onchange="PF('dataTable').filter();"
panelStyle="width:125px" scrollHeight="150">
<f:selectItems value="#{myBean.typeStrings}" />
</p:selectCheckboxMenu>
</f:facet>
<f:facet name="header">
<h:outputText value="Type"/>
</f:facet>
<h:outputText value="#{record.typeString}" />
</p:column>
In myBean
, there's a method which returns values I want to have on the panel in filter:
public List<String> getTypeStrings() {
List<String> typeStrings = new ArrayList<String>();
typeStrings.add("typeString1");
typeStrings.add("typeString2");
typeStrings.add("typeString3");
typeStrings.add("typeString4");
return typeStrings;
}
Filtering works as desired. After deploying to server, all checkboxes on the panel in filter are unchecked. When I check some of them, filter is applied. The problem is that after page refresh, filtering is not applied anymore (desired), but checkboxes keep their check states (some of them are checked). In the PF showcase example, all checkboxes are unchecked after refresh as expected.
I tried to add value="selectedTypeStrings"
to selectCheckboxMenu
, added this variable (list) to the bean and clear it in @PostContruct
method, but it didn't help.
How can I reset all those checkboxes after page refresh?
来源:https://stackoverflow.com/questions/32505881/selectcheckboxmenu-filter-values-not-reset-on-refresh