I have a component that I want to show/hide after user hits a commandButton
.
It's like this:
<h:commandButton id="showButton" value="#{bean.wasPressed ? 'Hide' : 'Show'}">
<f:ajax listener="#{bean.toggle()}" render="explanation showButton" />
</h:commandButton>
and
<h:panelGroup id="explanation" rendered="#{bean.wasPressed}">
<h:outputText value="something" />
</h:panelGroup>
The bean.toggle()
simply sets the wasPressed
property to true or false appropriately. I am using <h:form prependId="false">
.
The problem is the value of the render
attribute of my button. It explicitly enlists both: explanation
and showButton
.
As long as the showButton
is always present (it only changes its label), the explanation
is present only if the wasPressed
property is true. Otherwise it says:
malformedXML: During update: explanaition not found
How can I solve this problem?
I would like not to revert to hiding the element in the source code, so I would like not to use any jQuery toggle(-) or any way of hiding the element using style="display: none"
or any of this stuff.
Is it even achievable in JSF 2.1?