You're going to need a type converter which can convert from a String to
a Location object... Location could possibly be implemented usnig the
PersistentEnum pattern in Hibernate, otherwise you'll have to either:

A) do a lookup to the database to load the Location object for the city
(you seem to be passing the city as the value)

B) Maybe your locations collection already has all of the Location
objects and you can just look one up there to set

So after you implement your custom converter, you can look at
http://wiki.opensymphony.com/space/Type+Conversion for how type
conversion per-Action can be handled. 

You can also create a file named xwork-conversion.properties in the root
of your classpath with registrations for default type conversion types. 

Jason

> -----Original Message-----
> From: Donnerstag, Juergen [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, January 25, 2004 12:59 PM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] select tag
> 
> 
> 
> I'm using webwork2 and hibernate and I have a question 
> regarding the select tag. I checked the archives already, but 
> did not find an answer, which is why I send this request for help.
> 
> I have a class Employee and a class Location. Both classes 
> are defined in *.hbm.xml files and I can read and write data 
> to these tables. Given an employee I retrieve its location 
> simply by employee.getLocation().
> 
> I have designed a simple web form to input employee data and 
> a dropdown select box to select the location. The list is 
> initally filled with all locations (name of the city) from 
> the database plus an empty one to cover the cases where there 
> is no location yet assigned to an employee. Even 
> pre-selecting already existing relations to a location works. 
> However I've found no way yet to modify the location related 
> to an employee. I can't figure out where webwork stores the 
> selected value. My preferred solution would be. The 
> attributes list and listKey identify the object (of class 
> Location) and assigns that object 
> (employee.setLocation(location)) to the employee. But that 
> seems not to work. Any idea or solution?
> 
> <@ww.select label="'Location'" name="'employee.location'" 
> value="employee.location.id" list="locations" listKey="id" 
> listValue="city" />
> 
> thanks
> Juergen
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration 
> See the breadth of Eclipse activity. February 3-5 in Anaheim, 
> CA. http://www.eclipsecon.org/osdn 
> _______________________________________________
> Opensymphony-webwork mailing list 
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to