Bonjour tout le monde,
Je n'arrive pas encore à faire fonctionner un commandButton à l'intérieur d'une dataTable.
Voici mon code et mes traces :
mon cdiBean :
mon gestiondesdevis.xhtml :
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 package mdp.dpe.stea.dw.backingbeans; import java.io.Serializable; import java.util.List; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import mdp.dpe.stea.dw.backingbeans.util.JsfUtil; import mdp.dpe.stea.dw.commun.exception.CheckException; import mdp.dpe.stea.dw.commun.exception.NonExistentEntityException; import mdp.dpe.stea.dw.serveur.Devis; import mdp.dpe.stea.dw.serveur.Operation; import mdp.dpe.stea.dw.utilisation.IDevisService; import mdp.dpe.stea.dw.utilisation.IOperationService; /** * * @version 2014-08-26 * @author fg */ @Named @RequestScoped public class GestionDesDevis implements Serializable { @Inject private IOperationService opSvc; @Inject private IDevisService devisSvc; private Operation op; private Devis devis; private List<Devis> listeDeDevisPourOp; public GestionDesDevis(){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.GestionDesDevis() - CONSTRUCTEUR -"); } public Devis getDevis(){ if (op != null){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getDevis() id={0}", devis.getIdDevis()); } else { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getDevis() null"); } return devis; } public void setDevis(Devis devis) { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.setDevis()"); this.devis = devis; } public Operation getOp() { if (op != null){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getOp() id={0}",op.getIdOperation()); } else { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getOp() null"); } return op; } public void setOp(Operation op) { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.setOp({0})",op.getIdOperation()); this.op = op; } public List<Devis> getListeDeDevisPourOp(){ if (listeDeDevisPourOp != null){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getListeDeDevisPourOp() {0} items",listeDeDevisPourOp.size()); } else { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getListeDeDevisPourOp() null "); } return listeDeDevisPourOp; } public void setListeDeDevisPourOp(List<Devis> ld){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.getListeDeDevisPourOp()"); this.listeDeDevisPourOp=ld; } /** * c'est le point d'entree du formulaire * @param idOp * @return */ public String gererOperationAction(Integer idOp){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.gererOperationAction({0})",idOp); try{ op=opSvc.getOperation(idOp); listeDeDevisPourOp=(List<Devis>)op.getDevisCollection(); devis=new Devis(); }catch (NonExistentEntityException neee){ JsfUtil.addErrorMessage(neee, "opération non trouvée"); }catch (CheckException ce){ JsfUtil.addErrorMessage(ce, "opération trouvée non valide"); } return "gestiondesdevis"; } /** * * @param idDevis * @return */ public String editAction(Integer idDevis){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.editAction({0})", idDevis); try { devis = devisSvc.getDevis(idDevis); op = devis.getIdOperation(); listeDeDevisPourOp=(List<Devis>)op.getDevisCollection(); Logger.getLogger(GestionDesAgents.class.getName()).log(Level.INFO, "GestionDesDevis.editAction le devis est bien sélectionnée idDevis={0}", devis.getIdDevis()); } catch (NonExistentEntityException ne) { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.editAction addErrorMessage=", ne.getLocalizedMessage()); JsfUtil.addErrorMessage(ResourceBundle.getBundle("/messages").getString("gestionDesDevis_exceptionDevisNonTrouve") + " " + ne.getMessage()); return "gestiondesdevis"; } catch (CheckException ce) { Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.editAction addErrorMessage=", ce.getLocalizedMessage()); JsfUtil.addErrorMessage(ResourceBundle.getBundle("/messages").getString("gestionDesDevis_exceptionDevisNonChecke") + " " + ce.getMessage()); return "gestiondesdevis"; } return "gestiondesdevis"; } public String delAction(Integer idDevis){ Logger.getLogger(getClass().getName()).log(Level.INFO, "GestionDesDevis.delAction({0})", idDevis); return "gestiondesdevis"; } }
Ce qui est rageant c'est que les boutons hors de la dataTable fonctionnent mais pas ceux à l'intérieur de la dataTable...
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 <?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"> <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"> <body> <ui:composition template="..\WEB-INF\templates\layout.xhtml"> <ui:define name="titre"><h:outputText value="#{msg.gestionDesDevis_titrePage}"/></ui:define> <ui:define name="contenu"> <h2>#{msg.gestionDesDevis_titreH2}</h2> <h3>#{msg.gestionDesDevis_rappelOperation}</h3> <h3>#{msg.gestionDesDevis_titreFormSaisie}</h3> <h3>#{msg.gestionDesDevis_titreListing}</h3> <f:view> <h:form id="formListingDevis"> <h:inputHidden value="#{gestionDesDevis.op}" id="operation" /> <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/> <h:dataTable id="dtTable" value="#{gestionDesDevis.getListeDeDevisPourOp()}" var="item"> <h:column> <f:facet name="header"> <h:outputText value="IdDevis"/> </f:facet> <h:outputText value="#{item.idDevis}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="LibelleDevis"/> </f:facet> <h:outputText value="#{item.libelleDevis}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="actions"/> </f:facet> <h:commandButton action="#{gestionDesDevis.editAction(1)}" value="modifier"/><!--ne fonctionne pas--> <h:commandButton action="#{gestionDesDevis.delAction(1)}" value="supprimer"/><!--ne fonctionne pas--> </h:column> </h:dataTable> <h:commandButton action="#{gestionDesDevis.editAction(1)}" value="modifier"/><!--fonctionne--> <h:commandButton action="#{gestionDesDevis.delAction(1)}" value="supprimer"/><!--fonctionne--> </h:form> </f:view> </ui:define> </ui:composition> </body> </html>
Voici les traces en cliquant sur le bouton du haut :
Voici les traces en cliquant sur le bouton du bas :
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 INFO: ######EcouteurPhase.avantPhase RESTORE_VIEW 1 INFO: ######EcouteurPhase.aprèsPhase RESTORE_VIEW 1 INFO: ######EcouteurPhase.avantPhase APPLY_REQUEST_VALUES 2 INFO: GestionDesDevis.GestionDesDevis() - CONSTRUCTEUR - INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase APPLY_REQUEST_VALUES 2 INFO: ######EcouteurPhase.avantPhase PROCESS_VALIDATIONS 3 INFO: OperationConverter.getAsObject(fc,c,toto (1)) INFO: OperationConverter.getAsObject - identifiant = 1 INFO: GestionDesOperations.GestionDesOperations() - CONSTRUCTEUR - INFO: OperationService.getOperation(1) FIN: SELECT idOperation, AnneeTravaux, Description, Duree, DureeUnite, LibelleOp, Localisation, Periode, PeriodeUnite, TypeOp, loginAgent FROM operation WHERE (idOperation = ?) bind => [1 parameter bound] FIN: SELECT Login, Actif, Email, MotDePasse, Nom, Prenom FROM agent WHERE (Login = ?) bind => [1 parameter bound] INFO: GestionDesDevis.getOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase PROCESS_VALIDATIONS 3 INFO: ######EcouteurPhase.avantPhase UPDATE_MODEL_VALUES 4 INFO: GestionDesDevis.setOp(1) INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase UPDATE_MODEL_VALUES 4 INFO: ######EcouteurPhase.avantPhase INVOKE_APPLICATION 5 INFO: ######EcouteurPhase.aprèsPhase INVOKE_APPLICATION 5 INFO: ######EcouteurPhase.avantPhase RENDER_RESPONSE 6 INFO: EcouteurPhase.Phase RENDER_RESPONSE /utilisation/gestiondesdevis.xhtml INFO: GestionDesDevis.getOp() id=1 INFO: OperationConverter.getAsString(fc,c,object) INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase RENDER_RESPONSE 6
Ce que j'aimerai c'est de voir cette fameuse ligne "INFO: GestionDesDevis.editAction(1)" dans les traces de mes boutons du tableau entre les deux INVOKE APPLICATION...
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 INFO: ######EcouteurPhase.avantPhase RESTORE_VIEW 1 INFO: ######EcouteurPhase.aprèsPhase RESTORE_VIEW 1 INFO: ######EcouteurPhase.avantPhase APPLY_REQUEST_VALUES 2 INFO: GestionDesDevis.GestionDesDevis() - CONSTRUCTEUR - INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase APPLY_REQUEST_VALUES 2 INFO: ######EcouteurPhase.avantPhase PROCESS_VALIDATIONS 3 INFO: OperationConverter.getAsObject(fc,c,toto (1)) INFO: OperationConverter.getAsObject - identifiant = 1 INFO: GestionDesOperations.GestionDesOperations() - CONSTRUCTEUR - INFO: OperationService.getOperation(1) FIN: SELECT idOperation, AnneeTravaux, Description, Duree, DureeUnite, LibelleOp, Localisation, Periode, PeriodeUnite, TypeOp, loginAgent FROM operation WHERE (idOperation = ?) bind => [1 parameter bound] FIN: SELECT Login, Actif, Email, MotDePasse, Nom, Prenom FROM agent WHERE (Login = ?) bind => [1 parameter bound] INFO: GestionDesDevis.getOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase PROCESS_VALIDATIONS 3 INFO: ######EcouteurPhase.avantPhase UPDATE_MODEL_VALUES 4 INFO: GestionDesDevis.setOp(1) INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: GestionDesDevis.getListeDeDevisPourOp() null INFO: ######EcouteurPhase.aprèsPhase UPDATE_MODEL_VALUES 4 INFO: ######EcouteurPhase.avantPhase INVOKE_APPLICATION 5 INFO: GestionDesDevis.editAction(1) INFO: DevisService.getDevis(1) FIN: SELECT idDevis, LibelleDevis, Total, idLot, idOperation, loginAgent FROM devis WHERE (idDevis = ?) bind => [1 parameter bound] FIN: SELECT idLot, LibelleLot, idTitulaire FROM lot WHERE (idLot = ?) bind => [1 parameter bound] FIN: SELECT idTitulaire, Adresse1, Adresse2, Adresse3, CodePostal, Nom, Signataire, Tel, Ville FROM titulaire WHERE (idTitulaire = ?) bind => [1 parameter bound] FIN: SELECT idOperation, AnneeTravaux, Description, Duree, DureeUnite, LibelleOp, Localisation, Periode, PeriodeUnite, TypeOp, loginAgent FROM operation WHERE (idOperation = ?) bind => [1 parameter bound] FIN: SELECT Login, Actif, Email, MotDePasse, Nom, Prenom FROM agent WHERE (Login = ?) bind => [1 parameter bound] INFO: GestionDesDevis.editAction le devis est bien sélectionnée idDevis=1 INFO: ######EcouteurPhase.aprèsPhase INVOKE_APPLICATION 5 INFO: ######EcouteurPhase.avantPhase RENDER_RESPONSE 6 INFO: EcouteurPhase.Phase RENDER_RESPONSE /utilisation/gestiondesdevis.xhtml INFO: GestionDesDevis.getOp() id=1 INFO: OperationConverter.getAsString(fc,c,object) FIN: SELECT idDevis, LibelleDevis, Total, idLot, idOperation, loginAgent FROM devis WHERE (idOperation = ?) bind => [1 parameter bound] INFO: GestionDesDevis.getListeDeDevisPourOp() 2 items INFO: GestionDesDevis.getListeDeDevisPourOp() 2 items INFO: GestionDesDevis.getListeDeDevisPourOp() 2 items INFO: ######EcouteurPhase.aprèsPhase RENDER_RESPONSE 6
Ce que je ne comprends pas c'est pourquoi mon invoke application reste vide dans les boutons du tableau...
Un peu d'aide ne serait pas de refus
Cordialement, FG
Partager