1 Reply Latest reply on Jul 11, 2010 10:27 PM by Akaine Harga

    Start a4j:status after form validation?

    Michael Whitis Newbie

      I've got a simple form with one field and an a4j:commandbutton on  it.  Currently, when the button is clicked, the form is validated,  status starts and shows my modal form.  If the validation failes, the rich:message shows as appropriate, but it's under the modal form.

       

      Is there any way to have the  status start after the validation is complete so that the modal panel is  only shown when the validation is passed and the action actually gets called?

       

      My code is below:

       

                                <h:inputText
                                       id="ssoInput"
                                       styleClass="searchInput"
                                       value="#{myBean.sso}"
                                       required="true"
                                      label="User SSO"
                                   >
                                       <f:validateLength minimum="9" maximum="9"  />
                                   </h:inputText>

       

       

                                <a4j:commandButton
                                       id="addEntitlementButton"
                                       action="#{myBean.myAction}"
                                       eventsQueue="searchQueue"
                                        reRender="databaseStatusOutputText,databaseStatusModalBox"
                                       ignoreDupResponses="true"
                                       title="Add Entitlement"
                                       value="Add Entitlement"
                                       type="submit"
                                       styleClass="searchButton"
                                       status="statusModal"
                                   />

       

       

                               <a4j:status
                                       id="statusModal"
                                       onstart="databaseStart();"
                                         onstop="databaseFinished();"
                                   />

        • 1. Re: Start a4j:status after form validation?
          Akaine Harga Novice

          It's done without status actually.

           

          I assume databaseStatusModalBox is for displaying results and databaseStatusOutputText is for displaying errors. Then the commandButton would be:

          <a4j:commandButton
               id="addEntitlementButton" 
               action="#{myBean.myAction}"
               eventsQueue="searchQueue"
               reRender="databaseStatusOutputText,databaseStatusModalBox"
               ignoreDupResponses="true"
               title="Add Entitlement"
               value="Add  Entitlement"
               type="submit"
               styleClass="searchButton"
               oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.showModalPanel(\'databaseStatusModalBox\');' : ''}" />
          

           

          oncomplete always executes "after" the response is received, and our if-else expression guarantees that the the modal panel would appear only if there were no errors during the validation phase.

           

          PS: Delete a4j:status so it wouldn't be executed by default, or if you need it badly for other actions on the page point this commandButton's status attribute to some other id.