4 Replies Latest reply on Feb 11, 2011 7:22 AM by spiritfox26

    rich:messages as popup problem

    spiritfox26

      I'm using two rich:modalPanel, one to add data and other to display the rich:messages, the problem is this, when the modal with errors appear the modal with data disappear

       

      Anyone have a suggestion to resolve it?

       

      Thanks in advanced.

        • 1. rich:messages as popup problem
          ilya40umov

          I think that you should prive a sample of your code. Otherwise it's not possible to say what's wrong.

          • 2. rich:messages as popup problem
            spiritfox26

            Hi, thanks for  the answer

             

            Modal to add data:

             

            <rich:modalPanel id="addTipoCambio" width="400" height="220" resizeable="false">

                                <f:facet name="header">

                        <h:panelGroup>

                            <h:outputText value="#{msg.tiposCambioDataLabel}"></h:outputText>

                        </h:panelGroup>

                             </f:facet>

                                <a4j:form id="formTipoCambioAjax">

                                          <h:panelGrid columns="2" styleClass="modalStyle">

                                                    <h:panelGrid columns="2" styleClass="modalStyle">

                                                              <h:outputLabel id="nomTipoCambioLabel" value="#{msg.nomDominioLabel}"/>

                                                              <h:inputText id="nomTipoCambio" value="#{tiposCambioBean.nomTipoCambio}" required="true" label="#{msg.nomDominioLabel}">

                                                                        <f:validateLength minimum="1" maximum="30"/>

                                                              </h:inputText>

             

             

                                                              <h:outputLabel id="abrTipoCambioLabel" value="#{msg.abrDominioLabel}"/>

                                                              <h:inputText id="abrTipoCambio" value="#{tiposCambioBean.abrTipoCambio}" label="#{msg.abrDominioLabel}">

                                                                        <f:validateLength minimum="1" maximum="10"/>

                                                              </h:inputText>

                                                    </h:panelGrid>

                                                    <br/>

                                                    <h:panelGrid columns="1" styleClass="modalStyle">

                                                              <h:outputLabel id="dscTipoCambioLabel" value="#{msg.dscDominioLabel}"/>

                                                              <h:inputTextarea id="dscTipoCambio" cols="50" rows="4" value="#{tiposCambioBean.dscTipoCambio}" label="#{msg.dscDominioLabel}">

                                                                        <f:validateLength minimum="1" maximum="300"/>

                                                              </h:inputTextarea>

                                                    </h:panelGrid>

                                          </h:panelGrid>

                                          <table width="100%">

                                  <tbody>

                                      <tr>

                                    <td align="center" width="100%">

                                              <h:panelGrid columns = "2">

                                                                 <h:commandLink styleClass="ButtonYellowSmall78" rendered="#{not tiposCambioBean.editMode}" onmouseover="this.style.color='#0000CC';" onmouseout="this.style.color='black';"  value="#{msg.addDominioBtn}" action="#{tiposCambioBean.addTipoCambio}"></h:commandLink>

                                                                                            <h:commandLink styleClass="ButtonYellowSmall78" rendered="#{tiposCambioBean.editMode}" onmouseover="this.style.color='#0000CC';" onmouseout="this.style.color='black';"  value="#{msg.updateDominioBtn}" action="#{tiposCambioBean.updateTipoCambio}"></h:commandLink>

                                                                                            <a4j:commandLink reRender="formTipoCambioAjax" ajaxSingle="true" styleClass="ButtonYellowSmall78" onmouseover="this.style.color='#0000CC';" onmouseout="this.style.color='black';"  value="#{msg.selectCancelar}" action="#{tiposCambioBean.limpiar}" oncomplete="Richfaces.hideModalPanel('addTipoCambio');" limitToList="true"/>

                                                                                  </h:panelGrid>

                                                            </td>

                                </tr>

                            </tbody>

                        </table>

                                </a4j:form>

                      </rich:modalPanel>

             

             

            Captura.PNG

             

             

            Modal to display errors:

             

            <rich:modalPanel id="errorsPanel" showWhenRendered="#{not (facesContext.maximumSeverity==null)}" autosized="true" width="500">

                    <f:facet name="header">

                        <h:outputText value="#{msg.mensajesErroresLabel}"/>

                    </f:facet>

                    <f:facet name="controls">

                        <h:panelGroup>

                            <h:graphicImage value="/images/close.png" style="cursor:pointer" id="linkCierreErrores">

                            <rich:componentControl for="errorsPanel" attachTo="linkCierreErrores" operation="hide" event="onclick"/>

                            </h:graphicImage>

                        </h:panelGroup>

                    </f:facet>

                    <h:panelGrid columns="2" styleClass="columnaIzquierda">

                              <h:graphicImage value="/images/ErrorMessage.png" />

                              <rich:messages styleClass="mensajesError"/>

                                </h:panelGrid>

                </rich:modalPanel>

             

            Captura2.PNG

             

            When i press Add button the errors appear correctly, but the rich:ModalPanel to add data disappear.

             

            Thanks

            • 3. rich:messages as popup problem
              ilya40umov

              As I can see you are using h:commandLink inside your rich:modalPanel. That's why your whole page gets re-rendered after submit. And thus rich:modalPanel disappears.

              You have two options:

              1) add showWhenRendered="#{some EL}" to the first rich:modalPanel

              2) use a4j:commandButton but then showWhenRendered won't work for the second rich:modalPanel

              • 4. rich:messages as popup problem
                spiritfox26

                I think that, but in action method (in h:commandLink) i check some permission and redirect the page if the user not have this permission if i use a4j:commandLink (o a4j:commandButton) i have a new problem because don't use submit