now I need help with setting variable.
I have two entities Season and Tournament, tournament belongs to season.
So now I created one season and I see the list of this season. I have here one button “select” which should save actual season to session scope:
public String selectSezona(Sezona sezona){
this.sezona = sezona;
return "index";
}
so now I have selected one season and now I wanna created tournament in this season but I dont wanna select season so I write this:
<h:inputHidden value="#{turnaje.turnaj.setSezona(sezony.sezona)}" />
this is hidden input text which should assign actual season to this tournament but this wont work 🙁 . Error is: javax.el.PropertyNotWritableException . I see that season is set because I see its name. How tou figure this issue ? please help
thx
edit:
I also have getter and setter in tournament
@ManyToOne
private Sezona sezona;
public Sezona getSezona() {
return sezona;
}
public void setSezona(Sezona sezona) {
this.sezona = sezona;
}
but why should I have method setSezona without parameter ?
Well, you have a
selectSezona(...)method, but not asetSezona(...).In fact, your hidden field would require a property as its value, not a method.
Your
setSezona(...)doesn’t return anything, however, JSF needs a way to get the initial value.Thus, you’d need to change the expression to
#{turnaje.turnaj.sezona}.You’d still get an error, since JSF can’t convert between
StringandSezona, so you also need to provide a converter to your hidden field.