JSF - Unhide jsf component when clicking another component
I'm trying to have a button that brings up an upload dialog. The way i'm trying to achieve this is similar to this:
<h:outputText value="Click Me" id="testit">
<a4j:support reRender="hideme" event="onclick" action="#{actions.switchTestRendered}"/>
</h:outputText>
<h:outputText id="hideme" value="back" rendered="#{actions.testRendered}"/>
With code in the backing bean:
private boolean testRendered = false;
public开发者_如何学Python String switchTestRendered(){
setTestRendered(!isTestRendered());
System.out.println("Current Status:"+isTestRendered());
return "success";
}
public void setTestRendered(boolean testRendered) {
this.testRendered = testRendered;
}
public boolean isTestRendered() {
return testRendered;
}
When I press the 'click me' label I can see that the switchTestRendered is run but the 'hideme' component does not reveal.
Any suggestions? Thanks!
Got it. I should have reRendered the parent of the element which I'm trying to hide/show. In other words:
<a4j:support reRender="hideme" event="onclick" action="#{actions.switchTestRendered}"/>
should be:
<a4j:support reRender="father_of_hideme" event="onclick" action="#{actions.switchTestRendered}"/>
Thanks! Ben.
From the code it can only be seen that after 'Click me' the 'hide' component renderer is not updating. You have to find out why
精彩评论