Ok, I think I figured out my problem. I'll summarize here in the hopes that
this helps someone. I initially got the solution half right, by implementing
a Converter to convert between the String representation of an Employee and
an Employee object. However, I was still failing during the validation phase
even though I had implemented a "null" validator that always returned. The
problem is that the UISelectOne class has a "validateValue" method that
attempts to validate that the selected item is in fact contained within the
UISelectItems list. It does this by essentially calling
java.lang.Object.equals() on the selected object to compare it against items
in the list. Even though all the data fields within the Employee object
instances were the same, they had different object references, and therefore
were deemed to be different. This ultimately led to a failure during
validation. In order to solve this, I had to implement an equals method of
my own in the Employee class that overrides the default
java.lang.Object.equals method. This equals method compared the data fields
within two Employee objects and declared them equal if all fields were
equal.

To summarize, if you want to populate a UISelectOne control with a list of
objects that are not simple Strings, you need to do two things; implement a
Converter to go back and forth between String and Object, and override
java.lang.Object.equals with your own equals implementation that compares
the Object's data fields. Hope this helps someone out there. Good luck
finding this documented somewhere.

-- 
View this message in context: 
http://www.nabble.com/JSF-Newbie-needs-help-with-selectOneMenu-and-valueChangeListener-tf4341404.html#a12484864
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to