Click here to Skip to main content
       

Java

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalsynchronization validation and display of dialog in a primeface JSF2.0 form [modified]memberahmadiss7 Aug '12 - 2:42 
hello
I have a form with jsf2 and primefaces that contains a submit button that managed two things: First: form validation with the update attribute and second launching a confirmation dialog box when validation succeeded and all of this are managed by:
update="myfieldset display"
so my problem is that when I click into the button validation: if validation don't succeeded : validation messages are displayed in the form : ok but if the validation succeeded I must click a second time to display dialog box
anyone know how to solve this problem there?
 
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
 
 
 
    <script type="text/javascript">
        <!--
        function effacer(formulaire){
            for (var i=0; i<formulaire.length; i++){
                if (formulaire.elements[i].type=="input" || formulaire.elements[i].type=="textarea" ) {formulaire.elements[i].value="";}
            }
            document.getElementById('contenu_input').value="";
        }
        //-->
    </script>
 
    <body>
 
        <ui:composition template="./template_utilisateur.xhtml">
 
            <ui:define name="content">
                <h:form id="form" prependId="false" >  
                    <p:fieldset  id="myfieldset" legend="Nouveau message">
 
                        <p:messages id="msgs"/>
 
                        <h:panelGrid columns="3" style="margin-bottom:10px">
                            <h:outputLabel for="title" value="Titre : *"/> 
                            <p:inputText id="title" style="width:340px;" value="#{messageController.titre}" required="true" requiredMessage="veuillez saisir un titre" label="Titre">  
                                <f:validateLength minimum="10" />  
                            </p:inputText>  
                            <p:message for="title" display="icon"/>
                            <h:outputLabel for="city" value="Destinataire : *" /> 
                            <p:selectOneMenu id="city" value="#{messageController.destinataire}" label="Destinataire" required="true" requiredMessage="veuillez choisir au moins un destinataire" >  
                                <f:selectItem itemLabel="Séléctionner déstinataire" itemValue="" />  
                                <f:selectItems value="#{messageController.users}" />    
                            </p:selectOneMenu>  
                            <p:message for="city" id="msgSurname3" display="icon"/>
 
                            <h:outputLabel for="comm" value="Lié a La commande N° : " /> 
                            <p:selectOneMenu id="comm" label="Commande"  value="#{messageController.idComm}"  >  
                                <f:selectItem itemLabel="Aucune commande" itemValue="" />  
                                <f:selectItems value="#{messageController.id_c}" />    
                            </p:selectOneMenu>  
                            <p:message for="comm" id="msgSurnamse3" display="icon"/>
 
                        </h:panelGrid>
                        <h:outputLabel for="contenu" value="Contenu : *" /> 
                        <h:panelGrid columns="2">
                            <p:editor id="contenu" widgetVar="editer" value="#{messageController.message}" width="600" required="true" requiredMessage="Veuillez saisir le contenu du message" >
                                <f:validateLength minimum="10" /> 
                            </p:editor>  
                            <p:message for="contenu" id="editorm" display="icon"/>
                        </h:panelGrid>
 
                        <h:panelGrid columns="3">  
                            <p:commandButton id="submitButton" value="envoyer" update="myfieldset display"  onclick="#{messageController.retournerDialog()}" icon="ui-icon-disk" />  
                            <p:commandButton id="clearButton" type="reset" value="initialiser" onclick="editer.clear()"  
                                             icon="ui-icon-close" /> 
                        </h:panelGrid>  
 
                    </p:fieldset>  
 
                    <p:dialog header="Confirmation" widgetVar="dlg" showEffect="fade" hideEffect="fade" modal="true">  
                        <h:panelGrid id="display" columns="1" cellpadding="4">
                            <h:outputText value="Titre : " />  
                            <h:outputText value="#{messageController.titre}" id="model"/>  
 
                            <h:outputText value="Déstinataire :" />  
                            <h:outputText value="#{messageController.destinataire}" id="year"/>  
 
                            <h:outputText value="Lié à la commande N° : " />  
                            <h:outputText value="#{messageController.idComm}" id="manufacturer"/>  
 
                            <h:outputText value="Contenu :" />  
                            <h:outputText id="displxcay" value="#{messageController.message}" escape="false" />
                        </h:panelGrid>
 
                    </p:dialog>  
 
                </h:form>  
 
            </ui:define>
 
        </ui:composition>
 
    </body>
</html>
 
and here the method to launch the dialog :
public String retournerDialog(){
    String retour = "";
    if( getDestinataire() != "" && getMessage()!= "" && getTitre()!="" && getMessage().length()>9 && getTitre().length()>9){
        retour="dlg.show()";
    }
    return retour;
    }
 
thank you in advance

modified 7 Aug '12 - 9:31.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 20 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid