6 Replies Latest reply on Oct 8, 2008 4:29 PM by sarats

    How to: validate before clicking action to close modal dialo

      How can I call a validation method (in a modal dialog), that when a "failure" outcome is returned, the modal dialog remains open (to display the error message). Can jsFunction be used to prevent the hiding of the modal dialog on failure?

      Thanks in advance.

        • 1. Re: How to: validate before clicking action to close modal d

          what do you have now? What your action method returns?

          • 2. Re: How to: validate before clicking action to close modal d

            If I click Update Type button, updateTypeAction is called. Is there a way to not hide the modal panel if a updateTypeAction returns "failure".

             <!-- ==================== modal panel ====================== -->
             <rich:modalPanel id="travelerTypePanel" width="700" height="240">
             <f:facet name="header">
             <h:outputText value="Traveler Type Definition" />
             </f:facet>
             <f:facet name="controls">
             <h:form>
             <a4j:commandLink action="#{projectAdminView.clearTypeAction}" onclick="javascript:Richfaces.hideModalPanel('travelerTypePanel')">
             <h:outputText value="X" styleClass="panelControl" />
             </a4j:commandLink>
             </h:form>
             </f:facet>
             <h:panelGrid columns="1">
             <h:form>
             <a4j:outputPanel ajaxRendered="true">
             <h:panelGrid columns="1">
             <t:messages showSummary="false" showDetail="true" summaryFormat="{0}:" errorClass="errors" infoClass="info" />
             </h:panelGrid>
             </a4j:outputPanel>
             <a4j:outputPanel ajaxRendered="true">
             <h:panelGrid columns="2">
             <h:outputText value="Type Name:" styleClass="label-bold" />
             <h:panelGroup>
             <h:inputText id="typeName" value="#{projectAdminView.typeName}" disabled="#{projectAdminView.typeInUse}" size="20" maxlength="20">
             <a4j:support event="onchange" action="#{projectAdminView.checkTypeName}" />
             </h:inputText>
             </h:panelGroup>
             <h:outputText value="Type Description:" styleClass="label-bold" />
             <h:panelGroup>
             <h:inputText id="typeDescription" value="#{projectAdminView.typeDescription}" size="80" maxlength="128" />
             </h:panelGroup>
             </h:panelGrid>
             <h:panelGrid columns="1">
             <h:panelGroup>
             <a4j:commandButton value="Add Type" action="#{projectAdminView.addTypeAction}" styleClass="button-default" rendered="#{projectAdminView.addTypeButtonRendered}" />
             <a4j:commandButton value="Update Type" action="#{projectAdminView.updateTypeAction}" styleClass="button-default" rendered="#{not projectAdminView.addTypeButtonRendered}"/>
             <a4j:commandButton value="#{label.clearButton}" action="#{projectAdminView.clearTypeAction}" styleClass="button-default" rendered="#{not projectAdminView.typeInUse}"/>
             </h:panelGroup>
             </h:panelGrid>
             </a4j:outputPanel>
             <h:panelGrid columns="1">
             <a4j:commandLink action="#{projectAdminView.clearTypeAction}" onclick="javascript:Richfaces.hideModalPanel('travelerTypePanel')">
             <h:outputText value="Close" styleClass="link-large" />
             </a4j:commandLink>
             </h:panelGrid>
             </h:form>
             </h:panelGrid>
             </rich:modalPanel>
            


            • 3. Re: How to: validate before clicking action to close modal d

              Here is the correct code (without close button and onclick on update button).

               <!-- ==================== modal panel ====================== -->
               <rich:modalPanel id="travelerTypePanel" width="700" height="240">
               <f:facet name="header">
               <h:outputText value="Traveler Type Definition" />
               </f:facet>
               <f:facet name="controls">
               <h:form>
               <a4j:commandLink action="#{projectAdminView.clearTypeAction}" onclick="javascript:Richfaces.hideModalPanel('travelerTypePanel')">
               <h:outputText value="X" styleClass="panelControl" />
               </a4j:commandLink>
               </h:form>
               </f:facet>
               <h:panelGrid columns="1">
               <h:form>
               <a4j:outputPanel ajaxRendered="true">
               <h:panelGrid columns="1">
               <t:messages showSummary="false" showDetail="true" summaryFormat="{0}:" errorClass="errors" infoClass="info" />
               </h:panelGrid>
               </a4j:outputPanel>
               <a4j:outputPanel ajaxRendered="true">
               <h:panelGrid columns="2">
               <h:outputText value="Type Name:" styleClass="label-bold" />
               <h:panelGroup>
               <h:inputText id="typeName" value="#{projectAdminView.typeName}" disabled="#{projectAdminView.typeInUse}" size="20" maxlength="20">
               <a4j:support event="onchange" action="#{projectAdminView.checkTypeName}" />
               </h:inputText>
               </h:panelGroup>
               <h:outputText value="Type Description:" styleClass="label-bold" />
               <h:panelGroup>
               <h:inputText id="typeDescription" value="#{projectAdminView.typeDescription}" size="80" maxlength="128" />
               </h:panelGroup>
               </h:panelGrid>
               <h:panelGrid columns="1">
               <h:panelGroup>
               <a4j:commandButton value="Update Type" action="#{projectAdminView.updateTypeAction}" styleClass="button-default"
               rendered="#{not projectAdminView.addTypeButtonRendered}"
               onclick="javascript:Richfaces.hideModalPanel('travelerTypePanel')"/>
               </h:panelGroup>
               </h:panelGrid>
               </a4j:outputPanel>
               </h:form>
               </h:panelGrid>
               </rich:modalPanel>
              


              • 4. Re: How to: validate before clicking action to close modal d

                The second question is still important. Are you going to proceed to another page is validation is ok or you want to stay on the same page after the dialog is closed.

                • 5. Re: How to: validate before clicking action to close modal d
                  sarats

                  Was there ever a solution to this?

                  I too want to leave my modal open if the seam validation fails.

                  I am posting button code here:

                  <a:commandButton value="Save Changes" reRender="infoPanel"
                  action="#{processingManager.saveAddress}" oncomplete="javascript:Richfaces.hideModalPanel('editPanel')"/>


                  When the user clicks this button the modal is closed even if the validation fails. I want the modal to stay open.

                  Any help is greatly appreciated.

                  Thanks!