8 Replies Latest reply on Sep 14, 2007 7:47 PM by Sergey Smirnov

    a4j:commandButton and immediate attribute

    Fernando Montaño Expert

      I had the following code working in Ajax4JSF 1.1.1:

      <a4j:commandButton action="#{languageAction.cancel}" value="#{messages['Common.cancel']}"
       styleClass="button" immediate="true" ajaxSingle="true"/>
      


      After I upgraded to RichFaces 3.1.0 rc5 it does not work anymore. When I press such button nothing happens.

      If I remove immediate attribute or give a false value it works.

      Is that OK in RichFaces 3.1 ?

        • 1. Re: a4j:commandButton and immediate attribute
          Ilya Shaikovsky Master

          What do you mean under "doesn't work"? I've just places simple button on the page with immediate true - and able to see that the action is called for example.


          Give please more info,

          • 2. Re: a4j:commandButton and immediate attribute
            Fernando Montaño Expert

            I meant the action is not called.




            The facelet:

            
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
             xmlns:rich="http://richfaces.ajax4jsf.org/rich"
             xmlns:app="http://jatun.com/products/jrbundler/facelets"
             template="/layout/template.xhtml">
            <ui:define name="pageTitle">
             #{messages['User.new']}
            </ui:define>
            <ui:param name="mainMenu" value="admin"/>
            <ui:param name="bodyWidth" value="50%"/>
            <ui:define name="body">
            <h:form id="userForm">
            
            <div class="buttons">
             <a4j:commandButton action="#{userAction.create}" value="#{messages['Common.save']}"
             styleClass="button" reRender="formPanel" rendered="#{userAction.op == 'create'}"/>
            
            
            
             <a4j:commandButton action="#{userAction.cancel}" value="#{messages['Common.cancel']}"
             styleClass="button" immediate="true" ajaxSingle="true"/>
            
            </div>
            
            <rich:panel id="formPanel">
            <f:facet name="header">
             <s:fragment>
             <s:fragment rendered="#{userAction.op == 'create'}">
             #{messages['User.new']}
             </s:fragment>
             <s:fragment rendered="#{userAction.op == 'update'}">
             #{messages['User.edit']}
             </s:fragment>
             </s:fragment>
            </f:facet>
            
            <s:decorate id="usernameField" template="/include/inputField.xhtml">
             <ui:define name="label">#{messages['User.username']}</ui:define>
             <h:inputText id="username" value="#{user.username}" styleClass="input" required="true"
             maxlength="40" tabindex="1">
             <a4j:support event="onblur" reRender="usernameField"/>
             </h:inputText>
            </s:decorate>
            
            <s:decorate id="passwordField" template="/include/inputField.xhtml">
             <ui:define name="label">#{messages['User.password']}</ui:define>
             <h:inputSecret id="password" value="#{user.password}" required="true"
             maxlength="40" redisplay="true" tabindex="2" styleClass="input">
             <a4j:support event="onblur" reRender="passwordField"/>
             </h:inputSecret>
            </s:decorate>
            
            
            
            
            </rich:panel>
            
            <div class="buttons">
             <a4j:commandButton action="#{userAction.create}" value="#{messages['Common.save']}"
             styleClass="button" reRender="formPanel" rendered="#{userAction.op == 'create'}" tabindex="12"/>
            
            
             <a4j:commandButton action="#{userAction.cancel}" value="#{messages['Common.cancel']}"
             styleClass="button" immediate="true" ajaxSingle="true" tabindex="15"/>
            </div>
            
            </h:form>
            
            
            
            </ui:define>
            </ui:composition>
            
            
            


            • 3. Re: a4j:commandButton and immediate attribute
              Ilya Shaikovsky Master

              please use a phaseTracker to get info about phases execution in the server log. There you'll be able to see where the phases where the processing was unsuccesfull.

              • 4. Re: a4j:commandButton and immediate attribute
                Fernando Montaño Expert

                I upgraded to 3.1.0 but the problem persist. I used a phase tracker, below you can see my results.

                Using inmediate="true" I got:

                INFO 18:06:30,890 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: RESTORE_VIEW 1
                INFO 18:06:30,921 PhaseTrackerListener.java:19 AFTER PHASE CALLED: RESTORE_VIEW 1
                INFO 18:06:30,937 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: APPLY_REQUEST_VALUES 2
                INFO 18:06:30,953 PhaseTrackerListener.java:19 AFTER PHASE CALLED: APPLY_REQUEST_VALUES 2
                INFO 18:06:30,953 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: PROCESS_VALIDATIONS 3
                INFO 18:06:30,953 PhaseTrackerListener.java:19 AFTER PHASE CALLED: PROCESS_VALIDATIONS 3
                INFO 18:06:30,953 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: UPDATE_MODEL_VALUES 4
                INFO 18:06:30,953 PhaseTrackerListener.java:19 AFTER PHASE CALLED: UPDATE_MODEL_VALUES 4
                INFO 18:06:30,953 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: INVOKE_APPLICATION 5
                INFO 18:06:30,953 PhaseTrackerListener.java:19 AFTER PHASE CALLED: INVOKE_APPLICATION 5
                INFO 18:06:30,968 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: RENDER_RESPONSE 6
                INFO 18:06:31,000 PhaseTrackerListener.java:19 AFTER PHASE CALLED: RENDER_RESPONSE 6
                


                Using inmediate="false" I got:


                INFO 18:29:04,234 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: RESTORE_VIEW 1
                INFO 18:29:04,296 PhaseTrackerListener.java:19 AFTER PHASE CALLED: RESTORE_VIEW 1
                INFO 18:29:04,312 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: APPLY_REQUEST_VALUES 2
                INFO 18:29:04,343 PhaseTrackerListener.java:19 AFTER PHASE CALLED: APPLY_REQUEST_VALUES 2
                INFO 18:29:04,343 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: PROCESS_VALIDATIONS 3
                INFO 18:29:04,343 PhaseTrackerListener.java:19 AFTER PHASE CALLED: PROCESS_VALIDATIONS 3
                INFO 18:29:04,343 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: UPDATE_MODEL_VALUES 4
                INFO 18:29:04,343 PhaseTrackerListener.java:19 AFTER PHASE CALLED: UPDATE_MODEL_VALUES 4
                INFO 18:29:04,343 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: INVOKE_APPLICATION 5
                INFO 18:29:04,343 UserAction.java:96 CANCEL ACTION IS CALLED...
                INFO 18:29:04,343 PhaseTrackerListener.java:19 AFTER PHASE CALLED: INVOKE_APPLICATION 5
                INFO 18:29:04,390 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: RESTORE_VIEW 1
                INFO 18:29:04,390 PhaseTrackerListener.java:19 AFTER PHASE CALLED: RESTORE_VIEW 1
                INFO 18:29:04,437 PhaseTrackerListener.java:23 BEFORE PHASE CALLED: RENDER_RESPONSE 6
                INFO 18:29:04,859 PhaseTrackerListener.java:19 AFTER PHASE CALLED: RENDER_RESPONSE 6
                



                So, I don't know what is happening. I'm using Seam 2 Beta1, but as I told before I didn't touch anything in the code, I just upgraded to RichFaces 3.1 from 3.0.1 (where it was working).

                Any ideas?

                • 5. Re: a4j:commandButton and immediate attribute
                  Sergey Smirnov Master

                  ajaxSingle functionality has been moved to the server side (many reasons).

                  in general, immediate="true" skips the processing phases.

                  Currently, the ajaxSingle performs the processing phases only for itself (that is why you still see all 6th phases in the log). It means that the phases are not processed for other components.

                  In other words, you can try to avoid using immediate="true" in this particular case as soon as ajaxSingle="true" already does its job.

                  Of course, it is a bug that immediate="true" and ajaxSingle="true" on the same component do not work as expected. We are going to figure out the way how to return the behavior back to the right direction.

                  • 6. Re: a4j:commandButton and immediate attribute
                    rpa_rio Novice

                    I'm getting similar problem with a4j:commandLinks on version 3.1.0, my bean actions isn't called anymore on this version, the same problem doesn't happens on aj4 1.1.1 and RF 3.0.1

                    • 7. Re: a4j:commandButton and immediate attribute
                      rpa_rio Novice

                      But in my case I'm leaving the default immediate setting.

                      • 8. Re: a4j:commandButton and immediate attribute
                        Sergey Smirnov Master

                        wrapping the component with a4j:region is also an option.