1 Reply Latest reply on Feb 2, 2010 3:23 PM by robert walker

    help: a4j:commandButton not updating my bean

    robert walker Newbie

      Hi all, I have a a4j:commandButton that should be updating my bean,

      but my breakpoint in the action method invoked shows the property is null.



      If I simply change to h:commandButton then the property is set from a value on the form.


      I also added a MyPhaseListener.java whcih prints out logging in beforePhase() and afterPhase()

      I can confirm that if I use   h:commandButton   i see the update models phase being called (b4 and after)

      and if I use a4j:commandButton  I ALSO see update models phase being called (b4 and after)


      I also added 


      and viewing the log seems to show all my values are indeed leaving the client browser and heading to the server.


      My backing bean is defined like such



      @Name("mailboxManager") // identifies this as a Seam component, seam component name ="mailboxManager"
      public class MailboxManager implements Serializable





      I really wanted to use a4j:commandButton though cause I got a status indicator flashing until the response comes back which is great feedback to the user, and it looks great.  Love the whole richfaces components!!!!



      when stopping in my   mailboxManager.sendEmailToMailBox()    action method,

      I see my bean's (mailboxManager)    testEmailFromAddress    property

      is null, but changing to use h:commandButton it actually has one of the selected values from


      <h:selectOneMenu id="testMailboxFromListbox" value="#{mailboxManager.testEmailFromAddress}">


      must be something to do with  a4j:region ?


      any help would be greatly appreciated




      <rich:panel style="width:550px;border: 1px solid blue;padding:1em">
                  <a4j:form id="sendTestEmailForm">
                          <h:panelGrid columns="2">

                              <h:outputText styleClass="labelFont" value="From: " />
                              <h:selectOneMenu id="testMailboxFromListbox"
                                  <f:selectItem itemValue="anEmailAddress@bar.com" itemLabel="foo bar" />
                                  <f:selectItem itemValue="anotherEmail@foo.com"  itemLabel="abc def" />


                          <h:panelGrid columns="3" style="height:35px;">
                                  <a4j:region id="statusImg4">
                                      <a4j:commandButton id="sendTestEmailButton"
                                           value="Send Email to Mailbox"
                                           action="#{mailboxManager.sendEmailToMailBox}" />



                                            this works, stopping in mailboxManager.sendEmailToMailBox()

                                            shows mailboxManager.testEmailFromAddress has a    selected

                                            value from above

                                          <h:commandButton id="sendTestEmailButton"
                                                                   value="Send Email to Mailbox"
                                                                 action="#{mailboxManager.sendEmailToMailBox}" />


                                  <a4j:status for="statusImg4">
                                      <f:facet name="start">
                                          <h:graphicImage value="/images/ajax-loader2.gif"/>

                                  <rich:message for="sendTestEmailButton"

                                           <f:facet name="errorMarker"><h:graphicImage url="/images/failed.gif"/></f:facet>
                                           <f:facet name="infoMarker"><h:graphicImage url="/images/ok.gif"/></f:facet>



        • 1. Re: help: a4j:commandButton not updating my bean
          robert walker Newbie

          we'll, after my last edit of my initial approach, i got to thinking

          maybe that blasted a4j:region has something to do with it, so I went

          to max katz's book Practical Richfaces (EXCELLENT book on richfaces that everyone

          that uses richfaces should get) and low and behold




          <a4j:region> tag lets you specify which components will be

          processed (


          processed includes decoding, conversion, validation, and model

          updating) on the server. Keep in mind that the full form is still submitted.

          But, only components inside this region will be processed:



          so I moved my a4j:region to just after and the closing b4 the <a4j:form>

          and it works


          thaks so much max, now you need to write the missing manual on seam also  :-)