[Dialog] Les actions de boutons ne se déclenchent pas
Bonjour,
J'ai une dataTbale qui affiche des données et qui permet d'ouvrir un dialogue pour créer un nouvel enregistrement.
Mon problème est que les actions des 2 boutons de mon dialogue ne se déclenche pas quand je clique dessus.
Mon fichier xhtml:
Code:
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
<?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">
<ui:composition template="../../../secured/modele/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:define name="contenu">
<h:form id="dial">
<!-- boîte de dialogue -->
<p:confirmDialog widgetVar="confirmation" message="Confirmer la suppression" header="Entetes" severity="alert" >
<p:commandButton value="Oui" update=":formulaire:gestionSocietes" action="#{gestionSocietes.supprimerSociete}" oncomplete="confirmation.hide()"/>
<p:commandButton value="Non" onclick="confirmation.hide()" type="button"/>
</p:confirmDialog>
</h:form>
<h:form id="gestionSocietes">
<p:contextMenu for=":formulaire:gestionSocietes:societes">
<p:menuitem value="Supprimer" onclick="PF('confirmation').show()"/>
<p:menuitem value="Ajouter" onclick="PF('userAjout').show()"/>
</p:contextMenu>
<h2>
<h:outputText value="#{msg['GestionDesSocietes']}" />
</h2>
<p:dataTable id="societes"
value="#{gestionSocietes.listSocietes}"
var="societe" widgetVar="UserTable" filteredValue=""
emptyMessage="#{msg['AucuneSocieteAAfficher']}"
selection="#{gestionSocietes.selectedSociete}"
selectionMode="single" editable="false" editmode="row"
rowKey="#{societe.id}" paginator="true" paginatorPosition="bottom"
rows="10" style="margin-bottom:10px"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Rechercher un utilisateur par login : " />
<p:inputText id="globalFilter" onkeyup="UserTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column style="width:5%">
<f:facet name="header">
#
</f:facet>
#{societe.id}
</p:column>
<p:column style="width:20%">
<f:facet name="header">
#{msg['Abrege']}
</f:facet>
#{societe.abrege}
</p:column>
<p:column style="width:30%">
<f:facet name="header">
#{msg['Nom']}
</f:facet>
#{societe.nom}
</p:column>
<p:column style="width:45%">
<f:facet name="header">
#{msg['Description']}
</f:facet>
#{societe.description}
</p:column>
</p:dataTable>
</h:form>
<h:form id="ajouterSocieteBean">
<p:growl id="messages" showDetail="true"/>
<p:dialog header="#{msg['NouvelleSociete']}" widgetVar="userAjout" resizable="false" id="userAjout" >
<h:panelGrid id="ajoutDial" width="650" columns="3" style="margin:0 auto;">
<h:outputLabel for="abrege" value="#{msg['Abrege']} : " styleClass="mandatory" />
<p:inputTextarea rows="1" cols="50" counter="countAbrege" maxlength="10" counterTemplate="{0} #{msg['CaracteresDisponibles']}" autoResize="false" styleClass="unresizable" />
<h:outputText id="countAbrege" />
<h:outputLabel for="nom" value="#{msg['Nom']} : " styleClass="mandatory" />
<p:inputTextarea rows="2" cols="50" counter="countNom" maxlength="50" counterTemplate="{0} #{msg['CaracteresDisponibles']}" autoResize="false" styleClass="unresizable" />
<h:outputText id="countNom" />
<h:outputLabel for="description" value="#{msg['Description']} : " />
<p:inputTextarea rows="5" cols="50" counter="countDesc" maxlength="2000" counterTemplate="{0} #{msg['CaracteresDisponibles']}" autoResize="false" styleClass="unresizable" />
<h:outputText id="countDesc" />
<p:commandButton action="#{ajouterSocieteBean.ajouter}" update=":formulaire:gestionSocietes:societes messages" value="#{msg['Ajouter']}" icon="ui-icon-check"
style="margin:15px" oncomplete="userAjout.hide()"/>
<p:commandButton value="#{msg['Annuler']}" icon="ui-icon-check"
style="margin:15px" oncomplete="userAjout.hide()"/>
<!-- <p:message for="name" id="msg_name"/> -->
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
</ui:composition> |
Le bean du dialogue :
Code:
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
| @ManagedBean(name = "ajouterSociete")
@RequestScoped
public class AjouterSocieteBean {
private String abrege;
private String nom;
private String description;
/**
* Default Constructor
*/
public AjouterSocieteBean() {
}
public String getAbrege() {
return abrege;
}
public void setAbrege(String abrege) {
this.abrege = abrege;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void ajouter() {
Societe societe = new Societe();
societe.setAbrege(abrege);
societe.setNom(nom);
societe.setDescription(description);
}
} |
Celui du formulaire principal:
Code:
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
| @ManagedBean(name = "gestionSocietes")
@RequestScoped
public class GestionSocietesBean {
private List<Societe> listSocietes;
private Integer societeId;
private Societe selectedSociete;
@EJB
private SocieteDaoImpl m_societeDao;
/**
* Default Constructor
*/
public GestionSocietesBean() {
}
public SocietesDataTableModel getListSocietes() {
listSocietes = new ArrayList<>();
for (int i = 0; i < 8; i++) {
Societe u = new Societe();
u.setId(i);
u.setAbrege("nicolas");
u.setNom("nom");
listSocietes.add(u);
}
return new SocietesDataTableModel(listSocietes);
}
public Integer getSocieteId() {
return this.societeId;
}
public void setSocieteId(Integer societeId) {
this.societeId = societeId;
}
public Societe getSelectedSociete() {
return this.selectedSociete;
}
public void setSelectedSociete(Societe selectedSociete) {
this.selectedSociete = selectedSociete;
}
public void modifierSociete() {
// TODO
}
public void supprimerSociete() {
for (Societe soc :listSocietes) {
if (societeId == soc.getId()) {
listSocietes.remove(soc);
break;
}
}
}
} |
Qqun peut-il m'expliquer pourquoi les actions ne s'enclenchent pas ?
Merci d'avance pour votre aide