salut,
j'ai un problème, j'ai fait un programme qui ajoute et supprime des comptes, mais le problème est qu'il n'ajoute et supprime rien, il n'affiche même pas une erreur.
je vous mets une partie du code, si quelqu'un a une idée je suis prenant.....
voci la classe responsable d'ajout et de suppression
la classe responsable de binding avec la page jsp
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 public class ControllerData { //........ public void addCompte() { Personne newPersonne = new Personne("name", "firstName", "mail", new Compte("login", "password")); Compte cmpte = new Compte("jamal", "sellak"); newPersonne.setNom("ezzeel"); newPersonne.setNom("ezed"); newPersonne.setEmail("jezl@sezd.zen"); newPersonne.setCompte(cmpte); listD.getListOfpersonne().add(newPersonne); } public void deleteCompte() { Personne newPersonne = new Personne("", "", "", null); RSyncDataView rdv = new RSyncDataView(); this.listD.getListOfpersonne().removeAll(rdv.getSelectedObject()); } } }
la classe, qui contient les données à supprimer ou ajouter...
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 public class RSyncDataView implements ControllerInterface{ private UIData dataTable; private UISelectBoolean checkBox; public RSyncDataView(){ dataTable = new UIData(); checkBox = new UISelectBoolean(); } public UIData getDataTable() { return dataTable; } public void setDataTable(UIData dataTable) { this.dataTable = dataTable; } public UISelectBoolean getCheckBox() { return checkBox; } public void setCheckBox(UISelectBoolean checkBox) { this.checkBox = checkBox; } public List getSelectedObject(){ int size = dataTable.getRowCount(); List datas = (List)this.dataTable.getValue(); List selectedObject = new ArrayList(); for(int i =0; i<=size; i++){ dataTable.setRowIndex(i); if (this.checkBox.isSelected()) { selectedObject.add(datas.get(i)); } } return selectedObject; } }
enfin ma page jsp
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 public class ListData implements ModelInterface { private List<Personne> listOfpersonne = new ArrayList<Personne>(); private Compte compte; private Personne personne1; private UIData dataTable; public ListData() { compte = new Compte(); this.listOfpersonne.add(new Personne("dcscs", "cacar", "noumane@ahmed.zen", new Compte("anemane", "pwd"))); this.listOfpersonne.add(new Personne("toto", "toto", "toto@toto.zen", new Compte("toto", "toto"))); this.listOfpersonne.add(new Personne("tata", "tata", "tata@tata.zen", new Compte("tata", "tata"))); this.listOfpersonne.add(new Personne("titi", "titi", "titi@titi.zen", new Compte("titi", "titi"))); } /* .....................*/ }
voila, donc mon problème est le deux boutons "ajouter un compte" et "supprimer un compte".
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 <%@ page contentType="text/html" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="html" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="core" %> <core:view> <html:form> seule les personnes suiventes ont droit à se connecter: <html:dataTable binding="#{rSyncDataView.dataTable}" value="#{dataCcompte.listdata.listOfpersonne}" var="listP" border="1"> <html:column> <html:outputText value="#{listP.nom}"/> </html:column> <html:column> <html:outputText value="#{listP.prenom}"/> </html:column> <html:column> <html:selectBooleanCheckbox binding="#{rSyncDataView.checkBox}"/> </html:column> </html:dataTable> <html:commandButton value="Ajouter un Compte " action="#{controllerData.addCompte}"/> <html:commandButton value="Supprimer un Compte" action="#{controllerData.deleteCompte}"/> </html:form> </core:view>
que je clic sur l'un de deux boutons il y a rien qui passe
NB : j'ai bien fait mon manageBean
Partager