salut
j'ai deux tables direction 1 ---- 1* département je voulais ajouter un département qui contient une clé étrangère de la table direction DirectionID qui sera sous form de selectOneMenu voici le mon bean

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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
 
 
package managedbean;
 
 
 
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
 
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;
 
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
 
 
import metier.DepartementManagerImpl;
import metier.DirectionManagerImpl;
import metier.IDirectionManager;
 
import metier.IDepartementManager;
 
import dao.DirectionDAOImpl;
import dao.IDirectionDAO;
import departement.Departement;
import direction.Direction;
 
@ManagedBean(name="dept")
@SessionScoped
 
public class DepartementBean {
 
    IDepartementManager d=new DepartementManagerImpl();
    IDirectionManager dir = new DirectionManagerImpl();
    IDirectionDAO m=new DirectionDAOImpl();
 
    private Departement departement=new Departement();
 
    private Collection<SelectItem> directions=new ArrayList<SelectItem>();
 
    long directionidD;
    private long departementid;
    private String nomDept;
    private String chefDept;
    private Direction directionid;
 
 
 
    public long getDepartementid() {
        return departementid;
    }
 
    public void setDepartementid(long departementid) {
        this.departementid = departementid;
    }
 
    public String getNomDept() {
        return nomDept;
    }
 
    public void setNomDept(String nomDept) {
        this.nomDept = nomDept;
    }
 
    public String getChefDept() {
        return chefDept;
    }
 
    public void setChefDept(String chefDept) {
        this.chefDept = chefDept;
    }
 
    public Direction getDirectionid() {
        return directionid;
    }
 
    public void setDirectionid(Direction directionid) {
        this.directionid = directionid;
    }
 
 
 
    public DepartementBean(){
 
 
 
    }
 
 
 
    public long getDirectionidD() {
        return directionidD;
    }
 
 
 
    public void setDirectionidD(long directionidD) {
        this.directionidD = directionidD;
    }
 
 
 
    public Departement getDepartement() {
        return departement;
    }
 
    public void setDepartement(Departement departement) {
        this.departement = departement;
    }
 
    public DepartementBean(Departement departement) {
        super();
        this.departement = departement;
    }
 
 
 
public Collection<SelectItem> getDirections() {
 
    IDirectionManager dir = new DirectionManagerImpl();
    ArrayList<Direction> l=new ArrayList<Direction>();
    l.addAll(dir.ListeDirection("select d from Direction d "));
    for(int i=0;i<l.size();i++)
    {
        directions.add(new SelectItem(l.get(i).getDirectionid(),l.get(i).getNomDirection()));
 
    }
 
        return directions;
    }
 
    public void setDirections(Collection<SelectItem> directions) {
        this.directions = directions;
    }
 
 
blic String ajouterNewDepartement(){
 
        String forward="ok";
 
        Departement dept1=new Departement();
        dept1.setDepartementid(this.getDepartementid());
        dept1.setNomDept(this.getNomDept());
        dept1.setChefDept(this.getChefDept());
 
        Direction dd= rechercherDirection(this.getDirectionidD());
        dept1.setDirectionid(dd);
 
        d.ajoutDepartement(dept1);
 
 
        return "forward";
 
    }

Voici la vue

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
 
 
 
            Nom departement : <h:inputText
                        value="#{departementBean.departement.nomDept}"></h:inputText>
                    <br></br>
             chef departement: <h:inputText
                        value="#{departementBean.departement.chefDept}"></h:inputText>
                    <br></br>
 
            Direction: <h:selectOneMenu value="#{departementBean.directionid} ">
                    <f:selectItems  value="#{departementBean.directions}" />
                </h:selectOneMenu>
 
 
                </h:panelGrid>
                <br />
 
                <h:commandButton value="Save new Departement"
                    action="#{departementBean.ajouterNewDepartement}"
                    style="width: 156px" />


voici l'erreur :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
 
javax.servlet.ServletException: javax.el.PropertyNotWritableException: /GereDepartement.xhtml @28,72 value="#{departementBean.directionid} ": Illegal Syntax for Set Operation
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)