The reason the panel was minimized after each update was due to the use of static collapsed="true"on the panel. This can be fixed in one of two ways.
- Just refresh the contents of the panel, not the panel
- ajax
collapsed
, . , .
<p:panel header="#{category.applicationCategory.name}" id="panell"
toggleable="true" closable="false" toggleSpeed="500"
collapsed="true"
widgetVar="panel_#{category.applicationCategory.name}">
<h:form id="epsAppForm">
<h:panelGrid columns="2" border="0">
<h:outputLabel value="Select all"
style="font-weight: bold;float:left;" />
<p:selectBooleanCheckbox value="#{category.allSelected}">
<p:ajax event="change"
listener="#{epsEditController.selectionChanged(category)}"
update="@form" />
</p:selectBooleanCheckbox>
</h:panelGrid>
........
</h:form>
</p:panel>
EL
EL collapsed collapsed="true". -
collapsed="#{myBean.toggleStates[category.applicationCategory]}"
ajax
<p:ajax event="toggle" listener="#{myBean.toggleState(category.applicationCategory)" />
... myBean:
Map<ApplicationCategory, boolean> toggleStates = new HashMap<>();
... prepopulate toggleStates on @init or something
public void toggleState(ApplicationCategory myCategory) {
toggleStates.put(myCategory, !(toggleStates.get(myCategory));
}