3 Replies Latest reply on Mar 16, 2006 5:35 AM by Jens Weintraut

    Action method only invoked if immediate="true"

    Jens Weintraut Apprentice

      Hi there,

      I've some commandButtons on my page. My problem is that the action methods are only invoked if immediate is set to "true". The login of my app and the login of booking demo don't have immediate set to true, but both work. How can that be?

      Thanks
      Newlukai

        • 1. Re: Action method only invoked if immediate=
          Gavin King Master

          Are they in a form?

          In future, please provide code to go along with your questions.

          • 2. Re: Action method only invoked if immediate=
            Jens Weintraut Apprentice

            Sure, they are in a form. That's why I'm wondering about this behaviour.

            Here's the page:

            <ui:define name="content">
             <h:form>
             <div class="errors"><h:messages globalOnly="true" /></div>
             <div class="buttonLine">
             <h:commandButton action="#{showTestactionForDevelopers.saveTestaction}" image="img/showTestaction.save.gif" styleClass="graphical" />
             <h:commandButton action="#{showTestactionForDevelopers.saveTestactionAndNext}" image="img/showTestaction.saveAndNext.gif" styleClass="graphical" />
            
             <h:commandButton action="#{showTestactionForDevelopers.prevTestaction}" image="img/showTestaction.prev.gif" styleClass="graphical" immediate="true" />
             <h:outputText value="#{showTestactionForDevelopers.testactionIndexHR} | #{showTestactionForDevelopers.testactionsSize}" styleClass="indexAndSize" />
             <h:commandButton action="#{showTestactionForDevelopers.nextTestaction}" image="img/showTestaction.next.gif" styleClass="graphical" immediate="true" style="margin-left: 0px; margin-right: 15px;" />
             </div>
            
             <table cellpadding="0" cellspacing="0" border="0">
             <tr>
             <th><h:outputText value="#{ares_messages.label_testaction_ID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_TDate}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_TCaseID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_TesterUsrID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_EnvID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_SevID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_EditorUsrID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_DevUsrID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_RevID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_ChnglistID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_ValidatorUsrID}" /></th>
             <th> </th>
             </tr>
             <tr>
             <td><h:outputText value="#{currentTestaction.ID}" /></td>
             <td><h:outputText value="#{currentTestaction.TDate}" /></td>
             <td>
             <h:selectOneMenu value="#{currentTestaction.TCaseID}">
             <f:selectItems value="#{showTestactionForDevelopers.testcases}" />
             <f:convertNumber />
             </h:selectOneMenu>
             </td>
             <td><h:outputText value="#{currentTestaction.testerUsrID}" /></td>
             <td><h:outputText value="#{currentTestaction.envID}" /></td>
             <td><h:outputText value="#{currentTestaction.sevID}" /></td>
             <td><h:outputText value="#{currentTestaction.editorUsrID}" /></td>
             <td>
             <h:selectOneMenu value="#{currentTestaction.devUsrID}">
             <f:selectItems value="#{showTestactionForDevelopers.developers}" />
             <f:convertNumber />
             </h:selectOneMenu>
             </td>
             <td>
             <h:selectOneMenu value="#{currentTestaction.revID}">
             <f:selectItems value="#{showTestactionForDevelopers.revisions}" />
             <f:convertNumber />
             </h:selectOneMenu>
             </td>
             <td><h:inputText value="#{currentTestaction.chnglistID}"><f:convertNumber /></h:inputText></td>
             <td><h:outputText value="#{currentTestaction.validatorUsrID}" /></td>
             <td> </td>
             </tr>
             </table>
            
             <table cellpadding="0" cellspacing="0" border="0">
             <tr>
             <th><h:outputText value="#{ares_messages.label_testaction_CompID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_TCaseToken}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_Cost}" /></th>
             </tr>
             <tr>
             <td><h:outputText value="#{currentTestaction.compID}" /></td>
             <td><h:outputText value="#{currentTestaction.TCaseToken}" /></td>
             <td><h:inputText value="#{currentTestaction.cost}"><f:convertNumber /></h:inputText></td>
             </tr>
             </table>
            
             <table cellpadding="0" cellspacing="0" border="0">
             <tr>
             <th><h:outputText value="#{ares_messages.label_testaction_TestBNrID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_DevRelID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_DevBNrID}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_DefCID}" /></th>
             <th> </th>
             </tr>
             <tr>
             <td><h:outputText value="#{currentTestaction.testBNrID}" /></td>
             <td><h:outputText value="#{showTestactionForDevelopers.developerReleaseHR} (#{currentTestaction.devRelID})" /></td>
             <td><h:outputText value="#{currentTestaction.devBNrID}" /></td>
             <td><h:outputText value="#{currentTestaction.defCID}" /></td>
             <td> </td>
             </tr>
             </table>
            
             <table cellpadding="0" cellspacing="0" border="0">
             <tr>
             <th colspan="2"><h:outputText value="#{ares_messages.label_testaction_TCaseDescr}" /></th>
             </tr>
             <tr>
             <td colspan="2"><h:outputText value="#{currentTestaction.TCaseDescr}" styleClass="largeOutput" /></td>
             </tr>
             <tr>
             <th colspan="2"><h:outputText value="#{ares_messages.label_testaction_TCaseExpResult}" /></th>
             </tr>
             <tr>
             <td colspan="2"><h:outputText value="#{currentTestaction.TCaseExpResult}" styleClass="largeOutput" /></td>
             </tr>
             <tr>
             <th colspan="2"><h:outputText value="#{ares_messages.label_testaction_DefectDescr}" /></th>
             </tr>
             <tr>
             <td colspan="2"><h:outputText value="#{currentTestaction.defectDescr}" styleClass="largeOutput" /></td>
             </tr>
             <tr>
             <th><h:outputText value="#{ares_messages.label_testaction_DevRemark}" /></th>
             <th><h:outputText value="#{ares_messages.label_testaction_ValRemark}" /></th>
             </tr>
             <tr>
             <td><h:inputTextarea value="#{currentTestaction.devRemark}" /></td>
             <td><h:inputTextarea value="#{currentTestaction.valRemark}" /></td>
             </tr>
             </table>
             </h:form>
            </ui:define>


            And here is the component:
            @Stateful
            @Scope(ScopeType.SESSION)
            @LoggedIn
            @Name("showTestactionForDevelopers")
            @Interceptors(SeamInterceptor.class)
            public class ShowTestactionForDevelopers implements IShowTestactionForDevelopers{
             @PersistenceContext(unitName = "aresDatabase", type = PersistenceContextType.EXTENDED)
             private EntityManager em;
            
             @In
             @Valid
             private User user;
            
             @In
             private FacesContext facesContext;
            
             @In
             private Context sessionContext;
            
             @In(required=false)
             private List<Testaction> currentTestactions;
             @In(required=false)
             private Integer currentTestactionIndex;
             @In(required=false)
             @Out(required=false, scope=ScopeType.EVENT)
             @Valid
             private Testaction currentTestaction;
            
             private transient List<Testcase> testcases;
             private transient List<User> developers;
             private transient List<Revisionclass> revisions;
            
             public String saveTestaction() {
             saveCurrentTestaction();
             return "backToList";
             }
            }


            Sorry, that I didn't post the code, but I thought this problem was known.

            • 3. Re: Action method only invoked if immediate=
              Jens Weintraut Apprentice

              Something is really weird with my application.

              I removed the "immediate='true'". After hitting such a button a getter method of my component is invoked in the 'Process Validations' phase. This getter returns values for a selectOneMenu. But this getter requires the currentTestaction (the form which is submitted), which is null.
              To avoid the NPE I removed the selectOneMenus.
              When I then hit the button another getter method is invoked. Now in the 'Render response' phase. Only if I set 'immediate' to true, the action method is invoked.
              I don't understand why. And I don't understand why the currentTestaction is null. The _viewRoot of myFaces has the complete form with updated members.