4 Replies Latest reply on Aug 10, 2009 3:15 AM by yyq2009

    rich:modalPanel and ajax (UPDATE_MODEL_VALUES phase not exec

    margotmedia

      Hi!

      Now I am having another problem. It's the same in two different views and I didn't found any helpful resources among the internet.

      My problem seems to be the rich:modalPanel. My modalPanel code looks like the following:

      <rich:modalPanel id="createDgModalPanel">
       <f:facet name="header">
       <h:outputFormat value="#{messages['label.addgroup']}:" >
       <f:param value="#{EditTrialData.tf.trial.groupName}"/>
       </h:outputFormat>
       </f:facet>
       <h:form><div><h:outputText value="#{messages['label.groupname']}:" />
       <rich:spacer width="5"/>
       <h:inputText id="changeGroupNameIT" value="#{EditTrialData.newDataGroupName}"/>
       <br/>
       <rich:spacer height="10"/></div>
       <a:commandButton id="groupSaveButton"
       action="#{EditTrialData.createDg}"
       styleClass="button"
       title="#{messages['button.save']}"
       value="#{messages['button.save']}"
       reRender="dataGroupSelect"
       ajaxSingle="true">
       <rich:componentControl for="createDgModalPanel" attachTo="groupSaveButton" operation="hide" event="onclick"/>
       </a:commandButton>
       <rich:spacer width="5" />
       <a:commandButton
       styleClass="button"
       title="#{messages['button.cancel']}"
       value="#{messages['button.cancel']}"
       oncomplete="Richfaces.hideModalPanel('changeGroupNameMP')"
       type="reset"/></h:form>
      </rich:modalPanel>


      When the user is going to submit the form, the backing bean value "newDataGroupName" is not set. It's always null. It's a little bit confusing to me, because the following works:

      <div><rich:panel style="width:100%;">
       <b><h:outputFormat value="#{messages['label.addgroup']}:" >
       <f:param value="#{ViewTrialData.trial.groupName}"/>
       </h:outputFormat></b>
       <rich:spacer width="8"/>
       <h:inputText id="addDgTf" value="#{ViewTrialData.newDataGroupName}" onclick="javascript:if(this.value=='#{messages['label.newdatagroup']}') { this.value='' };"
       onblur="javascript:if(this.value==''){ this.value='#{messages['label.newdatagroup']}'; }"/>
       <rich:spacer width="8" />
       <a:commandButton id="addDgBtn" action="#{ViewTrialData.createDg}" styleClass="button"
       value="#{messages['button.add']}" title="#{messages['button.add']}" reRender="tree, trialFormsListPanel"
       eventsQueue="groupQueue" status="globalStatus" />
      </rich:panel>


      I can't find any significant difference between these two listings, except one time I am using a model panel and the second time I am using none.

      The listing without the modal panel works fine with ajax commandButton, the second in the modal doesn't work with ajax commandButton.

      I experienced this problem multiple times. Do I have a mistake in my code? Does anyone have an explanation for this?

      Thanks!

      regards,
      margotmedia.

        • 1. Re: rich:modalPanel and ajax (UPDATE_MODEL_VALUES phase not
          margotmedia

          What I forgot to mention: If someone is able to give me a working example it could be helpful too. What I want to do with the code mentioned above is the following:

          If the user clicks a link (in my case it's an a:commandLink) the modal panel should popup. In the modal panel the user can enter a name and after entering the name he clicks an a:commandButton, which executes an action (in my case persisting a new database record), closes the modal panel and finally rerenders the area on the actual page.

          I think it's a very simple use case, which wil be the case in many web applications. Unfortunately some problems with applying the parameters to the property in backing bean exist.

          So it would be nice if someone can give me a working example (or an explanation to this problem).

          • 2. Re: rich:modalPanel and ajax (UPDATE_MODEL_VALUES phase not
            margotmedia

            I solved it!

            I am now using a4j:form in conjuction with h:commandButton and of course ajaxSubmit="true". Now submitting works and I am very very happy!

            I have no clue, why the approach with h:form and a4j:commandButton didn't work. Maybe someone can explain it.

            regards,
            margotmedia.

            • 3. Re: rich:modalPanel and ajax (UPDATE_MODEL_VALUES phase not
              nbelaevski

              Hi margotmedia,

              I guess this

              <rich:componentControl for="createDgModalPanel" attachTo="groupSaveButton" operation="hide" event="onclick"/>
              is the cause. Try hiding modal panel by "oncomplete" event

              • 4. Re: rich:modalPanel and ajax (UPDATE_MODEL_VALUES phase not
                yyq2009

                Because of using ajaxsigle="true" with a:commandlink, if you remove this or add another attribute process="changeGroupNameIT", it will work normally.