5 Replies Latest reply on Mar 24, 2011 3:58 AM by Ilya Shaikovsky

    Modalpanel - commandButton action only called once

    Hai-Yun Du Newbie

      The commandButton action inside my modalPanel only gets called the first time it is clicked. Even after relogging in (starting a new session), the commandButton action is no longer called.

       

      <rich:modalPanel id="myPanel">
          <a4j:form>
              <a4j:outputPanel id="content">
                      <s:decorate template="/layout/edit.xhtml">
                          <ui:define name="label"><h:outputText value="Name"/></ui:define>
                          <h:inputText id="name" value="#{myPage.name}"/>
                      </s:decorate>
                      <s:decorate template="/layout/edit.xhtml">
                          <a4j:commandButton value="save"
                              action="#{myPage.save}"
                              reRender="content" />
                          <a4j:commandButton value="cancel"
                              onclick="#{rich:component('myPanel')}.hide()"/>
                      </s:decorate>
              </a4j:outputPanel>
          </a4j:form>
      </rich:modalPanel>
      
      @Name("myPage")
      @Scope (ScopeType.CONVERSATION)
      public class MyPage implements Serializable {
           private String name = "";
           // ... plus getters and setters
      
           public void save() {
                // Do save
           }
      }
      

       

      save() is only called the first time. Subsequent clicks on save does not call the action method.

        • 1. Modalpanel - commandButton action only called once
          Rocky S Master

          show us /layout/edit.xhtml

          • 2. Re: Modalpanel - commandButton action only called once
            Hai-Yun Du Newbie

            Here is edit.xhtml

             

            <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                             xmlns:ui="http://java.sun.com/jsf/facelets"
                             xmlns:h="http://java.sun.com/jsf/html"
                             xmlns:f="http://java.sun.com/jsf/core"
                             xmlns:s="http://jboss.com/products/seam/taglib">
                <div class="prop">
                    <s:span styleClass="name #{invalid ? 'errors' : ''}">            <ui:insert name="label"/>
                        <s:span styleClass="required" rendered="#{required}">*</s:span>
                    </s:span>
                    <span class="value #{invalid ? 'errors' : ''}">
                        <s:validateAll>
                            <ui:insert/>
                        </s:validateAll>
                    </span>
                    <s:span styleClass="error" rendered="#{invalid}">
                        <h:graphicImage value="/img/error.gif" styleClass="errors"/>
                        <h:messages styleClass="errors" />
                    </s:span>
                </div>
            </ui:composition>
            
            • 3. Re: Modalpanel - commandButton action only called once
              Ilya Shaikovsky Master

              use phasetracker and paste it's output for problematic request please

              • 4. Re: Modalpanel - commandButton action only called once
                Hai-Yun Du Newbie

                Output from phasetracker for first button click (on save). The save method checks the name for uniqueness, fails on validation and displays an error, which is the expected result:

                10:18:04,951 INFO  [helper] hdu BEFORE RESTORE_VIEW 1
                10:18:04,970 INFO  [helper] hdu AFTER RESTORE_VIEW 1
                10:18:04,975 INFO  [helper] hdu BEFORE APPLY_REQUEST_VALUES 2
                10:18:04,982 INFO  [helper] hdu AFTER APPLY_REQUEST_VALUES 2
                10:18:04,982 INFO  [helper] hdu BEFORE PROCESS_VALIDATIONS 3
                10:18:04,988 INFO  [STDOUT] hdu ******** get name John Doe
                10:18:04,991 INFO  [helper] hdu AFTER PROCESS_VALIDATIONS 3
                10:18:04,992 INFO  [helper] hdu BEFORE UPDATE_MODEL_VALUES 4
                10:18:04,995 INFO  [STDOUT] hdu ****** set name John Doe
                10:18:04,998 INFO  [helper] hdu AFTER UPDATE_MODEL_VALUES 4
                10:18:04,999 INFO  [helper] hdu BEFORE INVOKE_APPLICATION 5
                10:18:05,003 INFO  [STDOUT] hdu ****** inside save action method
                10:18:05,070 INFO  [STDOUT] hdu ***** failed validation in save: name not unique
                10:18:05,074 INFO  [helper] hdu AFTER INVOKE_APPLICATION 5
                10:18:05,080 INFO  [helper] hdu BEFORE RENDER_RESPONSE 6
                10:18:05,174 INFO  [STDOUT] hdu ******** get name John Doe
                10:18:05,355 INFO  [helper] hdu AFTER RENDER_RESPONSE 6
                

                 

                Output from phasetracker for subsequent button clicks (on save). It does not display any validation error.

                10:26:56,856 INFO  [helper] hdu BEFORE RESTORE_VIEW 1
                10:26:56,859 INFO  [helper] hdu AFTER RESTORE_VIEW 1
                10:26:56,862 INFO  [helper] hdu BEFORE APPLY_REQUEST_VALUES 2
                10:26:56,863 INFO  [helper] hdu AFTER APPLY_REQUEST_VALUES 2
                10:26:56,863 INFO  [helper] hdu BEFORE PROCESS_VALIDATIONS 3
                10:26:56,864 INFO  [helper] hdu AFTER PROCESS_VALIDATIONS 3
                10:26:56,864 INFO  [helper] hdu BEFORE UPDATE_MODEL_VALUES 4
                10:26:56,865 INFO  [helper] hdu AFTER UPDATE_MODEL_VALUES 4
                10:26:56,865 INFO  [helper] hdu BEFORE INVOKE_APPLICATION 5
                10:26:56,865 INFO  [helper] hdu AFTER INVOKE_APPLICATION 5
                10:26:56,868 INFO  [helper] hdu BEFORE RENDER_RESPONSE 6
                10:26:56,919 INFO  [helper] hdu AFTER RENDER_RESPONSE 6
                

                 

                However, I am also seeing now that sometimes the action is called the first few times, not just the first time.

                • 5. Re: Modalpanel - commandButton action only called once
                  Ilya Shaikovsky Master

                  do you able to create minimal project sample in order just to run locally?