| Author |
selectOneMenu to a managed bean
|
Michael Binette
Greenhorn
Joined: Jun 03, 2006
Posts: 3
|
|
I have this code in the JSF: where contract.contract.districtId points to a bean, class=District that has id, name, and region properties. contract.contract is a bean, class=Contract that has a districtId property that is of type class=District. contract.districtIds is a method that returns an array of SelectItem. The SelectItem is created with a value of a class=District bean and a label of the District.name property for example: When loading the JSF it properly shows the existing value but when I submit the form, without even changing the displayed value, my contract.contract.districtId object becomes null. I'm not really sure where to start looking for the cause. What am I doing wrong?
|
 |
Adam Mazurek
Greenhorn
Joined: Jun 02, 2006
Posts: 27
|
|
|
Can You show us the beans source code?
|
Regards<br />Adam Mazurek<br />SCJP 5<br />SCWCD 5
|
 |
Michael Binette
Greenhorn
Joined: Jun 03, 2006
Posts: 3
|
|
District (referenced by contract.contract.districtId) is an entity bean with generic getter and setters for the id, name, and region vars. Nothing special. Contract is an entity bean (referenced by contract.contract) with getter and setters for a ton of fields. The districtId property isn't really an Id. It is the District entity. The districtId getter and setters are: The JSF has a commandLink that with an action of "#{contract.edit}". The edit method looks like: where ContractService is an access layer on top of the entity beans. I debugged to this call and at the first line of this method, contract.districtId is null.
|
 |
Adam Mazurek
Greenhorn
Joined: Jun 02, 2006
Posts: 27
|
|
|
Maybe You should add this entity bean, which is on Your managed-bean as a managed property in config? I have problem with entity bean, which was a attribute of some bean - on page it was dissapearing. The solution was to add a markup <t:saveState >, but it is available only in myfaces.
|
 |
Michael Binette
Greenhorn
Joined: Jun 03, 2006
Posts: 3
|
|
I am new to JSF and I think I thought the oneSelectMenu had a little more "magic" than it really does. What I ended up trying that worked was to add a districtId property so instead of having the oneSelectMenu have a value of contract.contract.districtId which was pointing to a District object, I have the value be contract.districtId which is pointing to a Long in the backing bean. Then when they submit the form I use the contract.districtId to find the District and set contract.contract.districtId using it.
|
 |
 |
|
|
subject: selectOneMenu to a managed bean
|
|
|