The problem is that getAsObject should not return a new Person object, but the exactly the same object that was converted using getAsString. That means you either have to use something like t:saveState, session or conversation scoping or implement an equals method on person.
-Andrew On Wed, Mar 26, 2008 at 4:25 PM, Justin mcKay <[EMAIL PROTECTED]> wrote: > That's what I thought as well, but did not seem to work. Let's just say > that the Person object has only one parameter, id which is a Long. So the > getAsString method would just return the id. The getAsObject method would > create a Person object and set the id and return the Person. So far so > good. Well when I try and display the selectOneChoice it still does not > correctly select the proper Person. The log has an entry that says warning > could not find the Person object to be selected. So this suggests that the > value of the selectOneChoice does not get converted, only the selectItems. > This seems to be the case. I have three Persons in the selectItems and a > breakpoint in the converter's getAsString method. When I run it the > breakpoint is only reached three times, where I it should be four (one for > the selectOneChoice's value and three for the three selectItems). Is this > assumption incorrect? > > > > -----Original Message----- > From: Andrew Robinson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 26, 2008 2:03 PM > To: MyFaces Discussion > Subject: Re: [Trinidad] tr:selectOneChoice and Objects that cannot override > equals > > Use a custom converter on the choice that converts your object, or > register a class-converter for all the different classes in your app > that need to be converted. > > On Tue, Mar 25, 2008 at 4:50 PM, Justin Mckay <[EMAIL PROTECTED]> > wrote: > > > > > > > > > > I have a situation where I have some generated objects that do not > override > > equals that I would like to use in a selectOneChoice field. The issue is > > the selected object may not be the same object from the list of objects in > > the selectItems. For instance: > > > > > > > > <tr:selectOneChoice value="#{bean.person}"> > > > > <f:selectItems value="#{peopleFinder.people}"/> > > > > </tr:selectOneChoice> > > > > > > > > So here bean.Person is a generated type Person and peopleFinder.people > will > > be a Map<String,Person> of the same generated type. > > > > > > > > The way we have been handeling this is we have been wrapping the objects > > with another object that has a properly implemented equals method. This > > works but requires us to write more code, I was thinking there would be an > > easier way to do this, any ideas? > > > > > > > > Thanks, > > > > > > > > Justin > >

