Bonjour
Je suis entrain d'essayer l'injection des dépendances entre deux classes Vacation et Vacationtype mais elle ne marche pas je voulais afficher la liste des types de congés dans la page jsp d'ajout d'un congé.
voici mon code
mes deux objets persistants
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 public Vacation() { } public Vacation(Vacationtype vacationtype) { this.vacationtype = vacationtype; } public Vacation(Vacationtype vacationtype, String startDate, String endDate, Double duration, Integer numberOfWorkingDays, Integer halfDay, String createdAt, String deletedAt) { this.vacationtype = vacationtype; this.startDate = startDate; this.endDate = endDate; this.duration = duration; this.numberOfWorkingDays = numberOfWorkingDays; this.halfDay = halfDay; this.createdAt = createdAt; this.deletedAt = deletedAt; } @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "idvacation", unique = true, nullable = false) public Integer getIdvacation() { return this.idvacation; } public void setIdvacation(Integer idvacation) { this.idvacation = idvacation; } @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "vacationtype_idvacationtype") public Vacationtype getVacationtype() { return this.vacationtype; } public void setVacationtype(Vacationtype vacationtype) { this.vacationtype = vacationtype; } @Column(name = "Start_date", length = 65535) public String getStartDate() { return this.startDate; } public void setStartDate(String startDate) { this.startDate = startDate; } @Column(name = "End_date", length = 65535) public String getEndDate() { return this.endDate; } public void setEndDate(String endDate) { this.endDate = endDate; } @Column(name = "duration", precision = 22, scale = 0) public Double getDuration() { return this.duration; } public void setDuration(Double duration) { this.duration = duration; } @Column(name = "number_of_working_days") public Integer getNumberOfWorkingDays() { return this.numberOfWorkingDays; } public void setNumberOfWorkingDays(Integer numberOfWorkingDays) { this.numberOfWorkingDays = numberOfWorkingDays; } @Column(name = "half_day") public Integer getHalfDay() { return this.halfDay; } public void setHalfDay(Integer halfDay) { this.halfDay = halfDay; } @Column(name = "created_at", length = 65535) public String getCreatedAt() { return this.createdAt; } public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } @Column(name = "deleted_at", length = 65535) public String getDeletedAt() { return this.deletedAt; } public void setDeletedAt(String deletedAt) { this.deletedAt = deletedAt; }
Mon controlleur ou j'ai essayé l'injection
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 @SuppressWarnings("serial") @Entity @Table(name = "vacationtype", catalog = "proxym") public class Vacationtype implements java.io.Serializable { private Integer idvacationtype; private String type; public Vacationtype() { } public Vacationtype(Integer idvacationtype) { this.idvacationtype = idvacationtype; } public Vacationtype(Integer idvacationtype, String type) { this.idvacationtype = idvacationtype; this.type = type; } @Id @Column(name = "idvacationtype", unique = true, nullable = false) public Integer getIdvacationtype() { return this.idvacationtype; } public void setIdvacationtype(Integer idvacationtype) { this.idvacationtype = idvacationtype; } @Column(name = "type", length = 45) public String getType() { return this.type; } public void setType(String type) { this.type = type; }
Avez vous une solution 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 public class VacationController extends MultiActionController { private VacationDAO vacationDAO; private VacationtypeDAO vacationtypeDAO; protected final Log logger = LogFactory.getLog(getClass()); public void setVacationDAO(VacationDAO vacationDAO) { this.vacationDAO = vacationDAO; } public VacationDAO getVacationDAO() { return (vacationDAO); } public void setVacationtypeDAO(VacationtypeDAO vacationtypeDAO) { this.vacationtypeDAO = vacationtypeDAO; } public VacationtypeDAO getVacationtypeDAO() { return (vacationtypeDAO); } protected Object formBackingObject(HttpServletRequest request) throws Exception { Vacation defaultVacation = new Vacation(); defaultVacation.setStartDate("12211"); defaultVacation.setEndDate("15545"); defaultVacation.setDuration(20.00); defaultVacation.setNumberOfWorkingDays(4215247); defaultVacation.setHalfDay(013245); defaultVacation.setCreatedAt("11454"); defaultVacation.setDeletedAt("54154"); return defaultVacation; } @SuppressWarnings("unchecked") protected Map referenceData(HttpServletRequest request) throws Exception { Map<Object, Object> dataMap = new HashMap<Object, Object>(); dataMap.put("vacationtypeList", this.vacationtypeDAO .findallVacationtype()); return dataMap; }![]()
Partager