0

Suppose having a p:dialog with an <o:validateOne> on submit button where p:dialog will close after that the dialog closes even if the validation is still required

<h:form>
    <h:outputText id="newValueId" value="#{myBean.newValue}/>
    <p:dialog id="dialog" widgetVar="dlg" resizable="false" dynamic="true"
       appendToBody="false" modal="true">  
       <o:validateOne id="one" components="name1 name2"
          message="one is required"/>
       <h:panelGrid columns="2" cellpadding="5">  
          <h:outputLabel value="name 1 :" />  
          <p:inputText value="#{myBean.name1}" id="name1"/> 
          <h:outputLabel fvalue="name 2 :" />  
          <p:inputText value="#{myBean.name2}" id="name2"/>  

          <p:commandLink id="okId" value="ok" update="growl newValueId"   
             action="#{myBean.updateMyForm}"  
             process="dialog"
             oncomplete="if(!args.validationFailed())dlg.hide();"/>    
            </h:panelGrid>  
     </p:dialog>

class Mybean{

   String name1,name2,newValue;

   public void updateMyForm(){
      newValue=name1 + " " + name2;
   }

   //getter and setters
}

I want the dialog to not close if the two inputs input1 and input2 are still empty
But what what's happening is that dialog is closed and message is the displayed in the growl

Cœur
  • 37,241
  • 25
  • 195
  • 267
bob-cac
  • 1,272
  • 2
  • 17
  • 35
  • But your `oncomplete` clearly says so? It says: "if validation is failed, then hide dialog". Shouldn't you just negate the condition? – BalusC Jan 14 '14 at 08:47
  • ٍSorry mistake in copy paste i mean oncomplete="if(!args.validationFailed())dlg.hide();" – bob-cac Jan 14 '14 at 09:22
  • Sorry, works fine for me. By the way, `` must go inside ``, not outside. – BalusC Jan 14 '14 at 09:31
  • i am using one for all the html body and not one for the body and other for the is that matter in my problem also i used this in the oncomplete #{facesContext.postback and not facesContext.validationFailed} where the dialog stills opened but the message is not shown in the growl – bob-cac Jan 14 '14 at 09:34
  • Again, this code works fine for me, at least when copypasted into a completely blank playground project with sane defaults. The problem is caused elsewhere not visible in the information provided so far. An SSCCE would be helpful to naildown the cause. – BalusC Jan 14 '14 at 09:37

0 Answers0