A HashMap is used to track open tab state of a PrimeFaces p:accordionPanel:
@ViewScoped
public class SheetNav ... {
private Map<String, Integer> activeIndexAccordionMap = new HashMap<>();
@JSFviewParam
public Map<String, Integer> getActiveIndexAccordionMap() {
return activeIndexAccordionMap;
}
It's not important for this question where it is set (there are many different cases).
This works fine (but the initial state is not clear if activeIndexAccordionMap['accordion1']
was not set yet):
<p:accordionPanel
id="accordion1"
activeIndex="#{activeIndexAccordionMap['accordion1']}"
>
The following attempt to set a default initial state fails (the example below shows null
as the initial state, which is rather pointless, but the same happens for any specific value such as 1, 2, etc.):
<p:accordionPanel
id="accordion1"
activeIndex="#{(empty sheetNav.activeIndexAccordionMap['accordion1']) ? null : sheetNav.activeIndexAccordionMap['accordion1']}"
>
With error:
javax.el.PropertyNotWritableException: ... activeIndex="#{(empty sheetNav.activeIndexAccordionMap['accordion1']) ? null : sheetNav.activeIndexAccordionMap['accordion1']}": Illegal Syntax for Set Operation
Q: Why ?