joice
joice

Reputation: 53

primefaces dialog disappears when commandButton is submitted

I have a proble with dialog, here is my add.xhtml : when I click "Envoyer demande" I'm displaying a message of confirmation "Demande d'inscription envoyée" in the dialog but dialog disappears after clicking button "Envoyer demande" .

here is add.xhtm :

<h:form>
    <h:commandLink value="Créer un compte" onclick="dlg3.show();return false;"/>
  </h:form>

  <p:dialog id="modalDialoog" widgetVar="dlg3" draggable="false" resizable="false"      
        dynamic="true" header="Inscription">
  <center>
  <p:panel id="xyzBody">
  <h:form id="inscri-f">
  <h:panelGrid id="loginPan" columns="2" bgcolor="White">

 <h:outputText value="Nom d'utilisateur :" />
 <p:inputText id="username" value="#{demandeBean.login}"></p:inputText>

 <h:outputText value="Mot de passe :" />



<p:password id="pwd" value="#{demandeBean.pwd}"/>

 <h:commandButton value="Envoyer demande" update=":inscri-f:cr" 
         actionListener="#{demandeBean.envoi_dde}"></h:commandButton>



<h:commandButton value="Retour" action="page1?faces-redirect=true"></h:commandButton>

  <p:outputPanel id="cr"> 
    <h:outputText rendered="#{demandeBean.saved}" value="#{demandeBean.message}"/>
  </p:outputPanel>
        </h:panelGrid>
 </h:form>
 </p:panel>
 </center>
 </p:dialog>

my addBean.java :

 @ViewScoped
  public class DemandeBean implements Serializable{

 private static final long serialVersionUID = 1L;
 DdeDAO ndao = new DdeDaoImpl();
 private String login;
 private String pwd;
 private String message = "";
 private boolean saved = false;

 //getters and setters of all attributes

 public void envoi_dde(){

   Demande d = new Demande();
   d.setNom_ut(this.login);
   d.setPwd(this.pwd);
   ndao.nouvelle_dde(d);
   saved = true;
   this.setMessage("Demande d'inscription envoyée");

   }

I want dialog not to disappear after clicking button "Envoyer demande" .

Upvotes: 1

Views: 1554

Answers (1)

Hossein
Hossein

Reputation: 1201

1) change the h:commandButton to p:commandButton 2) set the ajax attribute of p:commandButton to true

this must work perfectly

Upvotes: 2

Related Questions