Bonjour,
J'ai dans une de mes pages, une dataTable à laquelle j'ai lié un contextMenu pour pouvoir supprimer une ligne de la table en ayant un dialogue qui demande la confirmation de la suppression.
Le problème est que l'action ne se déclenche pas et je ne vois pas ce qui pourrais engendrer cela.
Voici ma page :
Et le ManagedBean correspodant :
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 <?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="gestionUtilisateurs"> <h2> <h:outputText value="#{msg['GestionDesSocietes']}" /> </h2> <p:contextMenu for="societes"> <p:menuitem value="Supprimer" onclick="confirmation.show()"/> </p:contextMenu> <!-- boîte de dialogue --> <p:confirmDialog widgetVar="confirmation" message="Confirmer la suppression" header="Entetes" severity="alert" > <p:commandButton value="Oui" update=":formulaire:contenu" action="#{gestionSocietes.supprimerSociete}" oncomplete="confirmation.hide()"/> <p:commandButton value="Non" onclick="confirmation.hide()" type="button"/> </p:confirmDialog> <p:dataTable id="societes" value="#{gestionSocietes.listSocietes}" var="societe" widgetVar="UserTable" filteredValue="" emptyMessage="#{msg['AucuneSocieteAAfficher']}" selection="#{gestionSocietes.selectedSociete}" selectionMode="single" editable="true" 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"> <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> </ui:define> </ui:composition>
Qqun sait-il pourquoi cette action ne se déclenche pas ?
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 @ManagedBean @RequestScoped public class GestionSocietes { private List<Societe> listSocietes; private Integer societeId; private Societe selectedSociete; @EJB private SocieteDaoImpl m_societeDao; /** * Default Constructor */ public GestionSocietes() { } public SocietesDataTableModel getListSocietes() { listSocietes = new ArrayList<>(); for (int i = 0; i < 100; 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; } } } }
Merci d'avance pour votre aide
Partager