required fields and dialog hiding

UI Components for JSF
Post Reply
burakh79
Posts: 80
Joined: 17 Apr 2014, 10:22

24 Oct 2014, 17:17

My quesiton is when I add onclick="dlg2.hide()" to a commandbutton then I can see required fields warnings outside the dialog but if I remove onclick="dlg2.hide()" then I can see the warnings inside the dialog
What I would like to do is see the required fields warnings inside the dialog if some fields are empty then if there is no empty field hide the dialog page.
How can I do that ?
Primefaces 5.0
JSF 2.0
Eclipse Kepler
Apache Tomcat 7.0
Mozilla Firefox 30.0

BR_185
Posts: 1
Joined: 26 Oct 2014, 11:44
Location: Germany

26 Oct 2014, 12:13

Hi burakh79

in my sample application i used oncomplete instead of onclick

here a short example:

Code: Select all

<p:dialog id="addProvPopup" widgetVar="addProvDlg" resizable="false" modal="true"
  closable="false" closeOnEscape="false"
  appendTo="@(body)" showEffect="fade" hideEffect="fade" >
	
 <f:facet name="header">
    <h:outputText value="#{msgs.add}:&#160; " />
 </f:facet>
	
  <h:form id="addProvForm">
     <h:panelGrid id="addProvGrid" columns="3" cellpadding="5">

       <p:outputLabel id="addProvReportnumberLabel" value="#{msgs.provReportnumber}: " 
          for="addProvReportnumber" />
       <p:inputText id="addProvReportnumber"
          value="#{provisionModel.provReportnumber}"
          required="true" requiredMessage="#{msgs.requiredMsg}"
          validatorMessage="#{msgs.reportnumberMsg}" >
         <f:validateLength minimum="8" maximum="9" />
       </p:inputText>
       <p:message id="addProvReportnumberMsg" for="addProvReportnumber" />

     </h:panelGrid>
		
     <p:commandButton
           value="#{msgs.close}" immediate="true"
           oncomplete="PF('addProvDlg').hide(); return false;"
           action="#{propertyModel.reset()}" update="addProvGrid" />
			
     <p:commandButton id="addProvSaveButton" style="float:right"
          value="#{msgs.save}"
          action="#{provisionCtr.addProv()}"
          oncomplete="if (args && !args.validationFailed) PF('addProvDlg').hide()"
          update="addProvForm"
          process="@form"
     />
  </h:form>
</p:dialog>
Lars
______________________________
PrimeFaces 5.3 | Tomcat 8.0.30 | MyFaces 2.2.0
Firefox 44.0.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests