Bonsoir les ami(e)s
Je développe une application j2ee avec richface 4.0.0 j'utilise un calendrier dans un formulaire. Quand je modifie les dates, Eclipse m'affiche le message suivant :
javax.servlet.ServletException: Cannot convert com.ai.dto.Materiel@1145db8 of type class com.ai.dto.Materiel to int
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
Problème de cast mais je ne sais pas comment le régler.

Voilà la page materiel.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 com.ai.dto;
 
import java.util.Date;
import java.util.Vector;
 
public class Materiel {
 
	private Integer pk;
	private String n_serie;
	private String date_entree;
	private String date_sortie;
	private String etat;
	private String facture;
	private String commentaire;
	private Contrat contrat = new Contrat();
	private TypeMateriel typeMateriel = new TypeMateriel();
	private Vector<Panne> panneVect = new Vector<Panne>();
	private Vector<Logiciel> logicielVect = new Vector<Logiciel>();
 
	private Date dateOperation;
	private Date dateFinOperation;
 
	public Materiel() {
		super();
	}
 
	public Integer getPk() {
		return pk;
	}
 
	public void setPk(Integer pk) {
		this.pk = pk;
	}
 
	public String getN_serie() {
		return n_serie;
	}
 
	public void setN_serie(String n_serie) {
		this.n_serie = n_serie;
	}
 
	public String getDate_entree() {
		return date_entree;
	}
 
	public void setDate_entree(String date_entree) {
		this.date_entree = date_entree;
	}
 
	public String getDate_sortie() {
		return date_sortie;
	}
 
	public void setDate_sortie(String date_sortie) {
		this.date_sortie = date_sortie;
	}
 
	public String getEtat() {
		return etat;
	}
 
	public void setEtat(String etat) {
		this.etat = etat;
	}
 
	public String getFacture() {
		return facture;
	}
 
	public void setFacture(String facture) {
		this.facture = facture;
	}
 
	public String getCommentaire() {
		return commentaire;
	}
 
	public void setCommentaire(String commentaire) {
		this.commentaire = commentaire;
	}
 
	public Contrat getContrat() {
		return contrat;
	}
 
	public void setContrat(Contrat contrat) {
		this.contrat = contrat;
	}
 
	public TypeMateriel getTypeMateriel() {
		return typeMateriel;
	}
 
	public void setTypeMateriel(TypeMateriel typeMateriel) {
		this.typeMateriel = typeMateriel;
	}
 
	public Vector<Panne> getPanneVect() {
		return panneVect;
	}
 
	public void setPanneVect(Vector<Panne> panneVect) {
		this.panneVect = panneVect;
	}
 
	public Vector<Logiciel> getLogicielVect() {
		return logicielVect;
	}
 
	public void setLogicielVect(Vector<Logiciel> logicielVect) {
		this.logicielVect = logicielVect;
	}
	public Date getDateOperation() {
		return dateOperation;
	}
 
	public void setDateOperation(Date dateOperation) {
		this.setDate_entree(Dto.dbDateFormat.format(dateOperation));
		this.dateOperation = dateOperation;
	}
	public Date getDateFinOperation() {
		return dateFinOperation;
	}
 
	public void setDateFinOperation(Date dateFinOperation) {
		this.setDate_sortie(Dto.dbDateFormat.format(dateFinOperation));
		this.dateFinOperation = dateFinOperation;
	}
 
}

et la page de modification updateMateriel.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
<!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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<ui:composition template="template.xhtml">
	<ui:define name="content">
<h:head>
<title>Modifier Materiel</title>
</h:head>
<h:body>
<h2>Modifier Materiel</h2>
<table border="0">
<tr><td colspan="2" align="left"> <h:messages/> </td> </tr>	
 
<tr>
<td id="n_serie" align="right"><span style="size: 15px !important;">num de serie:&nbsp;</span></td>
<td>
<h:inputText id="n_serie" value="#{materielCtrl.materiel.n_serie}" required="true" requiredMessage="num est obligatoire"/>&nbsp;<h:message for="type"/></td>
</tr>			
 
							<tr style="height: 2px;"></tr>
<tr>
<td id="date_entree" align="right"><span style="size: 15px !important;">date_entree:&nbsp;</span></td>
<td id="tdValue">
<rich:calendar value="#{materielCtrl.materiel.dateOperation}" required="true"
										requiredMessage="Date d'entree est obligatoire" datePattern="dd.MM.yyyy"></rich:calendar>
</td>
</tr>
							<tr style="height: 2px;"></tr>
<tr>
<td id="date_sortie" align="right"><span style="size: 15px !important;">date_sortie :&nbsp;</span></td>
<td id="tdValue">
<rich:calendar value="#{materielCtrl.materiel.dateFinOperation}" required="true"
										requiredMessage="date_sortie est obligatoire" datePattern="dd.MM.yyyy"></rich:calendar>
</td></tr>
							<tr style="height: 2px;"></tr>
<tr>
<td id="etat" align="right"><span style="size: 15px !important;">etat :&nbsp;</span></td>
<td>
<h:inputText id="etat" value="#{materielCtrl.materiel.etat}" required="true" requiredMessage="etat est obligatoire"/>&nbsp;<h:message for="etat"/></td>
</tr>
							<tr style="height: 2px;"></tr>
							<tr>
<td id="facture" align="right"><span style="size: 15px !important;">Facture :&nbsp;</span></td>
<td>
<h:inputText id="facture" value="#{materielCtrl.materiel.facture}" required="true" requiredMessage="facture est obligatoire"/>&nbsp;<h:message for="etat"/></td>
</tr>
							<tr style="height: 2px;"></tr>
							<tr>
<td id="commentaire" align="right"><span style="size: 15px !important;">commentaire :&nbsp;</span></td>
<td>
<h:inputText id="commentaire" value="#{materielCtrl.materiel.commentaire}" required="true" requiredMessage="commentaire est obligatoire"/>&nbsp;<h:message for="commentaire"/></td>
</tr>
							<tr style="height: 2px;"></tr>
<tr>																				
<td>Type Matériel </td>
<td><h:selectOneMenu value="#{materielCtrl.materiel.typeMateriel.pk}"
style="width:140px;">
 
<f:selectItems value="#{materielCtrl.typeMaterielVect}" var="amine"
itemLabel="#{amine.nom}" itemValue="#{amine.pk}"></f:selectItems>
</h:selectOneMenu> <h:message for="typeMateriel" />
</td>
</tr>
 
<tr style="height: 2px;"></tr>
 
<tr>
<td colspan="2" align="right">
<h:commandButton action="#{materielCtrl.update}" value="valider" />
</td></tr>
		</table>
</h:body>
</ui:define>
</ui:composition>
</html>