3 Replies Latest reply on Mar 10, 2011 8:04 AM by ilya_shaikovsky

    Keep open modal dialog after pressing h:commandLink

    xmdx

      Hi guys.

       

      I have a modal panel, which is closing after i press the commandLink.

      Here is the code:

       

      <rich:modalPanel id="modalTrading">

      <h:form id="formModalTrading">

                <s:validateAll>

       

                     <s:decorate template="/components/inputField.xhtml">

                               <h:inputText value="#{tradingForm.value}"

                               requiredMessage="#{msg.trading_error}" required="true" />

                     </s:decorate>

       

                     <h:commandLink value="#{msg.tradingOrder_next}"

                               action="#{tradingAction.toStep2}">

                               <a4j:support ajaxSingle="true" event="onclick" reRender="formModalTrading"

                                         oncomplete="Richfaces.showModalPanel('modalTrading')"/>

                     </h:commandLink>

       

       

                </s:validateAll>

      </h:form>

      </rich:modalPanel>

       

      If i use a4j:commandLink instead of h:commandLink, validation of input fields doesnt work.

       

      Please, help me keeping it open after pressing the commandLink.

        • 1. Keep open modal dialog after pressing h:commandLink
          ilya_shaikovsky

          your code actually rises two concurrent requests - normal one and ajax one in the same time. And that's not correct design anyway.

           

          So please return just a4j:command without any support inside back. And just wrap your decorate with ajax rendered outputPanel or point with reRender. I believe validation is working with a4j:command, just nothing updated so you not seeing ther results.

          • 2. Re: Keep open modal dialog after pressing h:commandLink
            xmdx

            Hi Ilya,

            Thanks for the answer, but it doesnt work for me with a4j:commandLink.

             

            If you use h:commandLink, it doesn't start action method if there are any validation errors. But with a4j:commandLink it doesn't try make validation, just starts the action method. And the values of input fields in the modalPanel does not go to our bean (tradingForm) when we press the commandLink.

             

             

            Here is the code with a4j, maybe you see any mistakes in it:

             

            <rich:modalPanel id="modalTrading">

            <h:form id="formModalTrading">

                      <s:validateAll>

             

                           <s:decorate template="/components/inputField.xhtml">

                                     <h:inputText value="#{tradingForm.value}"

                                     requiredMessage="#{msg.trading_error}" required="true" />

                           </s:decorate>

             

                            <a4j:commandLink action="#{tradingAction.toStep2()}"

                                oncomplete="Richfaces.showModalPanel('modalTrading')"

                                reRender="modalTrading"

                                ajaxSingle="true"

                                value="#{msg.tradingOrder_next}">

                                          </a4j:commandLink>


                      </s:validateAll>

            </h:form>

            </rich:modalPanel>

             

            Thank you!

            • 3. Re: Keep open modal dialog after pressing h:commandLink
              ilya_shaikovsky

              just remove ajaxSingle = true. If it present nothing except the submitting component are decoded.

              1 of 1 people found this helpful