Hi,
When the following page is rendered at first, only "Display Form" button is displayed.
And when this button is clicked, helloAction.enableSayHelloForm() method is called.
But thereafter, the button does not disappear with it having been displayed.
Also "sayHelloForm" form is not displayed as expected.
Why?
...... <a4j:outputPanel id="enableSayHelloFormPanel" rendered="#{! helloAction.displaySayHelloForm}"> <h:form id="enableSayHelloForm"> <a4j:commandButton reRender="enableSayHelloFormPanel, sayHelloFormPanel" action="#{helloAction.enableSayHelloForm()}" value="Display Form" /> </h:form> </a4j:outputPanel> <a4j:outputPanel id="sayHelloFormPanel" rendered="#{helloAction.displaySayHelloForm}"> <h:form id="sayHelloForm"> <h:inputText value="#{helloAction.name}" /> <h:commandButton type="submit" action="#{helloAction.sayHello()}" value="Hello" /> <a4j:commandButton reRender="enableSayHelloFormPanel, sayHelloFormPanel" action="#{helloAction.disableSayHelloForm()}" value="Cancel" /> </h:form> </a4j:outputPanel> ... ...
// Seam component @Name("helloAction") @Scope(ScopeType.CONVERSATION) public class HelloAction { private boolean displaySayHelloForm; public isDisplaySayHelloForm() { return displaySayHelloForm; } public void enableSayHelloForm() { displaySayHelloForm = true; } public void disableSayHelloForm() { displaySayHelloForm = false; } private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } public String sayHello() { ...... } ...... }
you should not reRender conditionally rendered elements. Wrap them to one more parent and reRender the parent.