I have an application where I create a list of SelectItems like the following. Note the value of the SelectItem is a Location object which is a class of my own.

locations = new ArrayList<SelectItem>();
Session s = SessionManager.getSession();
Collection<Location> c = s.createQuery("from Location l order by l.name").list();
for(Location l : c) {
locations.add(new SelectItem(l, l.getName()));
}


Then, I have a JSP which makes use of the list like the following.

<h:selectOneMenu id="location" required="true" value="#{scheduleFinder.schedule.location}">
<f:selectItems value="#{scheduleFinder.locations}"/>
</h:selectOneMenu>


What I want it do is store the actual Location object that the user selected. Instead, I receive an error message like the following.

Conversion Error setting value '[4, USITE/Crerar]' for 'null Converter'.

The Location object is being converted into a String and the string is being attempted to be stored to the destination value.

I'm guessing that I need to create a custom converter to do what I want to do. What I'm wondering is, why doesn't JSF just lookup the object from the SelectItem list and store that value to the destination value? It seems like the whole string to value value to string business is a lot more work than it should be. Am I missing something?

Jon



Reply via email to