1 Reply Latest reply on Apr 1, 2008 6:59 AM by ilya_shaikovsky

    NEWBIE: How to switch a4j:outputPanel to display

    kiyo

      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() {
       ......
       }
      
       ......
      }
      


      How can I implement these things?
      (1)If "Display Form" button is clicked, the button disappears and "sayHelloForm" is displayed (using ajax).
      (2)If "Cancel" button in "sayHelloForm" form is clicked, "sayHelloForm" form disappears and "Display Form" button appears (using ajax).

      Thanks in advance.

      --
      RichFaces 3.1.3.GA
      JBoss Seam 2.0.1.GA(seam-gen project)
      JBoss AS 4.2.2.GA
      JDK 5.0 Update 15