1 Reply Latest reply on Feb 27, 2008 11:39 AM by Al Mathison

    form rerendering and A4J

    Al Mathison Newbie

      Hi All,

      I have some a form that contains <a4j:commandButton> tags that reRender the form. After the first reRender, the commandButtons cease to work. I have created a simple page and backing bean that show the problem I'm having.

      I'm using Facelets, Seam and EJB3


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       <head><title>Feedback Test</title></head>
       <h:form id='formSend'>
       <s:div id='divFeedback'>
       <s:fragment rendered='#{not testAction.initialized and not testAction.sent}'>
       <p>Step 1: Hit Initialize</p>
       <a4j:commandButton id='cmdInit' action='#{testAction.init}' reRender='divFeedback' value='Initialize'/>
       <s:fragment rendered='#{testAction.initialized}'>
       <p>Step 2: Hit Send</p>
       <a4j:commandButton id='cmdSend' action='#{testAction.send}' reRender='divFeedback' value='Send'/>
       <s:fragment rendered='#{testAction.sent}'>
       <p>Step 3: Done</p>
       <p>If you can see this, then this page is working correctly.</p>
       <a4j:commandButton id='cmdClear' action='#{testAction.clear}' reRender='divFeedback' value='Start Over'/>

      Backing Bean:
      package com.mc.test;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.ScopeType;
      public class TestAction {
       Log log;
       private String state;
       public TestAction() { }
       public void init() {
       log.debug("Do init()");
       this.state = "initialized";
       public void send() {
       log.debug("Do send()");
       this.state = "sent";
       public void clear() {
       log.debug("Do clear()");
       this.state = null;
       public Boolean getInitialized() { return "initialized".equals(this.state);}
       public Boolean getSent() { return "sent".equals(this.state);}

      Upon clicking the Initialize button, the testAction.init action is invoked, and the form re-renders Step 2, as it should. However, then clicking Send does not invoke the testAction.send action.

      I found that if I change the scope of the backing bean to Session, the form re-renders correctly, but that is not an option for our production site.

      Any help would be greatly appreciated,