Bonjour,

Pour les ajouts, j'aimerais faire des boutons Dialog pour ne pas surcharger les formulaires et le tout dans un Layout. Sauf que <p:commandButton> ne fonctionne pas. A l'extérieur du Layout, ça fonctionne.

La page html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
 
    <ui:composition template="/Views/Template/common.xhtml">
    <ui:define name="Edition">
    <h:form id="form">
        <p:growl id="msgs" />
        <p:panel header="Nouveau">
            <h:panelGrid columns="2" id="grid">
            <h:outputLabel value="ID : *" for="txt_id" />
                <p:inputText id="txt_id" value="#{typeCarburantBean.typeCarburant.idCarburant}"
                    required="true" />
                <h:outputLabel value="Libelle : *" for="txt_lib" />
                <p:inputText id="txt_lib" value="#{typeCarburantBean.typeCarburant.libelle}"
                    required="true" />
 
                <h:outputLabel value="prix : *" for="txt_prix" />
                <p:inputText id="txt_prix" required="true"
                    value="#{typeCarburantBean.typeCarburant.prixLitre}" />
 
                 <p:commandButton value="Reset" type="reset" />
                <p:commandButton id="btn_add" value="AJOUT"
                    action="#{typeCarburantBean.addTypeCarburant}" />
            </h:panelGrid>
        </p:panel>
    </h:form>
    </ui:define>
    <ui:define name="Consultation">
 
     <h:form id="AjoutP">
            <p:commandButton value="Ajouter un Vehicule" icon="ui-icon-adds"   onclick="CarburantAjout.show()"/>
        </h:form>
                <h:form id="edit">
 
            <p:dialog header="Ajout un Vehicule" widgetVar="CarburantAjout" resizable="true" id="editP" >
 <p:growl id="growl" showDetail="true" sticky="false" />
 
                <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
 
 
                    <f:facet name="header">
                        <h:outputLabel value="bonjour"/>
                    </f:facet>
 
 
 
                    <h:outputLabel for="id" title="id" value="id:" style="color: crimson;" />
                    <h:inputText value="#{typeCarburantBean.typeCarburant.idCarburant}"  id="id" required="true"/>
                    <h:outputLabel for="libelle"  value="libelle:" style="color: crimson;"/>
                    <h:inputText value="#{typeCarburantBean.typeCarburant.libelle}"  id="libelle" required="true"/>
                    <h:outputLabel for="prix" title="prix" value="prix" style="color: crimson;"/>
 
                    <h:inputText value="#{typeCarburantBean.typeCarburant.prixLitre}"   id="prix" required="true"/>
 
                </h:panelGrid>
                <p:separator/>
                <p:commandButton value="Enregistrer" actionListener="#{typeCarburantBean.addTypeCarburant}"  oncomplete="CarburantAjout.hide()"  />
            </p:dialog>
            </h:form>
     <h:form id="tbb"> 
 
 
              <p:outputPanel>  
                   <h:outputText value="Search:" style="Height:30px"/>  
                   <p:inputText id="globalFilter" onkeyup="TypeCarburant.filter()" style="width:150px" />  
              </p:outputPanel>  
        <p:dataTable id="dataTable" var="typeCarburant" value="#{typeCarburantBean.alltype}" sortMode="single" rows="5" paginator="true">    
 
            <p:column sortBy="#{typeCarburant.idCarburant}" headerText="ID" >  
                <h:outputText value="#{typeCarburant.idCarburant}" />  
            </p:column>  
 
            <p:column sortBy="#{typeCarburant.libelle}" headerText="Libelle">  
                <h:outputText value="#{typeCarburant.libelle}" />  
            </p:column>  
 
            <p:column sortBy="#{typeCarburant.prixLitre}" headerText="prix par litre">  
                <h:outputText value="#{typeCarburant.prixLitre}" />  
            </p:column> 
 
        </p:dataTable>  
 
    </h:form>  
    </ui:define>
 
    </ui:composition>
</html>
le bean
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package project.beans;
 
 
import java.util.List;
 
import javax.faces.bean.ViewScoped;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
 
import project.metier.mouse.TypeCarburant;
import project.service.TypeCarburantService;
 
@Component
@ViewScoped
//@ManagedBean(name="carb")
public class TypeCarburantBean {
    private TypeCarburant typeCarburant;
    private TypeCarburantService carburantService;
 
 
 
    public TypeCarburantBean(){
        typeCarburant=new TypeCarburant();
 
    }
 
 
    public  List<TypeCarburant> getAlltype(){
        return carburantService.getAlltype();
 
        }
    public String editCarburant(){
 
        return "new_carburant";
    }
 
    public String newCarburant(){
        reinit();
        return "new_carburantr";
    }
 
    public void reinit(){
        typeCarburant=new TypeCarburant();
    }
    /*
     * public String editPerson(){
        return "new_person";
    }
 
    public String newPerson(){
        reinit();
        return "new_personr";
    }
 
    public void reinit() {
        person = new Person();
    } 
     * 
     */
 
    public void addTypeCarburant(){
        carburantService.addTypeCarburant(typeCarburant);
    }
 
    public TypeCarburant getTypeCarburant() {
        return typeCarburant;
    }
 
    public void setTypeCarburant(TypeCarburant typeCarburant) {
        this.typeCarburant = typeCarburant;
    }
 
    @Autowired
    public void setCarburantService(TypeCarburantService carburantService) {
        this.carburantService = carburantService;
    }
}
Quelqu'un saurait-il m'indiquer comment faire ?

Merci d'avance pour votre aide.