s:selectItems and s:convertEntity
stereoscope Apr 23, 2008 2:06 PMHi!
i tried to put in a component into my jsf page! suddenly many obstacles came into my way. after a while i figured out how to come along with this issue but i have some questions.
well i have an entity representing a location and another entity which describes a locationType and the address entity holding the address for the specific location.
@Entity
public class Location {
private Long id;
private String name;
private Address address;
private String description;
private LocationType locationType;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="address_fk")
public Address getAddress() {
return address;
}
@OneToOne
@JoinColumn(name="locationType_fk")
public LocationType getLocationType() {
return locationType;
}
@Entity
public class LocationType {
private Long id;
private Location location;
private String locationType_de;
private String locationType_en;
@OneToOne(mappedBy = "locationType")
public Location getLocation() {
return location;
}
@Entity
public class Address {
private Long id;
private String countryNameCode;
private String administrativeAreaName;
private String subAdministrativeAreaName;
private String localityName;
private String thoroughfareName;
private String postalCodeNumber;
private GLatLng coordinates;
private User user;
private Location location;
@OneToOne(mappedBy = "address")
public User getUser() {
return user;
}
@OneToOne(mappedBy = "address")
public Location getLocation() {
return location;
}
furthermore i have written down a form and i want to display the different types of locations in a dropdown box. this actually works. i did this way that i fill a list with locationtype objects and add the objects attributes either englisch or german to a list of the type SelectItems
to pass it to the page...
but i dont know how to merge the chosen value from the selectonemenu back to an object.
or is there an easier way!?
public ArrayList<SelectItem> getLocationType() {
types = em.createQuery("Select type from LocationType type").getResultList();
for (LocationType loc : types) {
locationType.add(new SelectItem(loc.getLocationType_de()));
}
return locationType;
}anybody an idea!?