We have got two caf_h:panelBlock elements (id="panel1"
and id="panel2"
) in a CAF portlet which are supposed to be rendered based on a property of the backing bean (rendered="#{ViewBean.property}"
and rendered="#{not ViewBean.property}"
).
So the XHTML of such a panel locks as follows:
<caf_h:panelBlock id="panel1" rendered="#{ViewBean.property}">
content
</caf_h:panelBlock>
The property of the backing bean is declared as follows:
private java.lang.Boolean property;
And initialized in the bean's Initialize() method:
public String initialize() {
this.property = true;
}
The tricky part comes now: We want to show/hide these panels by clicking on a command link:
<caf_h:commandLink action="#{ViewBean.click}" id="commandLink"></caf_h:commandLink>
The bean method called by this command link, in turn, changes the property's value:
public String click() {
this.property = false;
}
However, the visibility/rendering of the block panels is not affected at all. What might be the reason?
It turned out that the above mentioned way works fine if the ViewBean.property
is not changed again later during the portlet life cycle - as we accidentally did in our case in the beforeRenderResponse()
method.