Bonjour a tous,
Je suis actuellement bloqué suite a un formulaire que j'ai créé
je ne parviens pas a lier la valeur récupérer a mon beanManage
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 <h:form> <h:panelGrid columns="2" cellpadding="5"> <pf:outputLabel for="numero" value="Numero"/> <pf:inputText id="numero" value="#{commmandeMB.cmd.numero}"/> <pf:outputLabel for="dateCmd" value="De de commande"/> <pf:inputText id="dateCmd" value="#{commmandeMB.cmd.dateCmd}"> <f:convertDateTime pattern="dd-MM-yyyy"/> </pf:inputText> <pf:outputLabel for="remise" value="Remise"/> <pf:inputText id="remise" value="#{commmandeMB.cmd.remise}"/> <pf:outputLabel for="user" value="Adherent"/> <pf:selectOneMenu id="user" value="#{commmandeMB.cmd.user}"> <f:selectItems value="#{commmandeMB.lstClts}" var="u" itemLabel="#{u.nom}" itemValue="#{u}" /> </pf:selectOneMenu> <pf:commandButton action="#{commmandeMB.ajouterCmd()}" value="Valider"/> </h:panelGrid> </h:form>
Le champs qui a pour ID user est doit être lier a l'attribut cmd dans ma classe CommmandeMB
Mon objet Commande a un attribut qui est la classe UserEntity et je ne parviens pas lier a mon formulaire.
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 @ManagedBean @RequestScoped public class CommmandeMB { private Commande cmd = new Commande(); private List<UserEntity> lstClts = new ArrayList<UserEntity>(); private List<Commande> lstCommandes = new ArrayList<Commande>(); public CommmandeMB() {} /** * @return the cdm */ public Commande getCmd() { return cmd; } /** * @param cdm the cdm to set */ public void setCmd(Commande cmd) { this.cmd = cmd; } /** * @return the lstClts */ public List<UserEntity> getLstClts() { return lstClts; } /** * @param lstClts the lstClts to set */ public void setLstClts(List<UserEntity> lstClts) { this.lstClts = lstClts; } /** * @return the lstCommandes */ public List<Commande> getLstCommandes() { return lstCommandes; } /** * @param lstCommandes the lstCommandes to set */ public void setLstCommandes(List<Commande> lstCommandes) { this.lstCommandes = lstCommandes; } public void initLst() { lstClts = UserDAO.listUsers(); lstCommandes = CommandeDao.listCommandes(); } public void createNumeroCommande() { Date d = new Date(); String num = new SimpleDateFormat("yyMMdd").format(d); String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; int charLength = chars.length(); StringBuilder pass = new StringBuilder (charLength); for (int x = 0; x < 4; x++) { int i = (int) (Math.random() * charLength); pass.append(chars.charAt(i)); } cmd.setNumero(num+pass.toString()); cmd.setRemise("0.0"); } public String ajouterCmd() { System.out.println(cmd); System.out.println(); CommandeDao.ajout(this.cmd); System.out.println("--------FIN------------"); return "ajoutCmd?faces-redirect=true"; } }
Est ce que l'un d'entre vous pourrais m'aider me debloquer svp
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 @Entity(name="commande") @Table(name="commande") public class Commande implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id_cmd") private int iCmd; private String numero; @Temporal(TemporalType.DATE ) @Column(name = "date_cmd") private Date dateCmd; private String remise; @ManyToOne private UserEntity user; public Commande() { super(); } /** * @return the iCmd */ public int getiCmd() { return iCmd; } /** * @param iCmd the iCmd to set */ public void setiCmd(int iCmd) { this.iCmd = iCmd; } /** * @return the numero */ public String getNumero() { return numero; } /** * @param numero the numero to set */ public void setNumero(String numero) { this.numero = numero; } /** * @return the dateCmd */ public Date getDateCmd() { return dateCmd; } /** * @param dateCmd the dateCmd to set */ public void setDateCmd(Date dateCmd) { this.dateCmd = dateCmd; } /** * @return the remise */ public String getRemise() { return remise; } /** * @param remise the remise to set */ public void setRemise(String remise) { this.remise = remise; } /** * @return the user */ public UserEntity getUser() { return user; } /** * @param user the user to set */ public void setUser(UserEntity user) { this.user = user; } @Override public String toString() { return "Commande [iCmd=" + iCmd + ", numero=" + numero + ", dateCmd=" + dateCmd + ", remise=" + remise + ", user=" + user + "]"; } }
Partager