Why is everybody overriding things like combobox to do this? You could cook
up a util to do it in 15 minutes.

In fact, I'll be back in 15 minutes.

On Thu, Oct 16, 2008 at 8:25 AM, frank_sommers <[EMAIL PROTECTED]>wrote:

> Thanks for the replies.
>
> Well, Jitendra's solution worked only when I created a ComboBox subclass
> that did take a
> special equals() (based on the value of a property named "id") into
> account. Basically, I
> overrode the selectedItem property in this subclass.
>
> I think equals() and hashCode() are absolutely important, and I find that
> it's a pain that
> Flex doesn't have them: In collection contains() methods, selecting items
> in controls, etc.,
> an equals() semantic is really important. There are many duplicate objects
> that are
> semantically equivalent in RIA clients, and without well-defined semantics
> for equality I'm
> finding that I have to implement this sort of logic in components myself.
>
> Any chance that this may be addressed in forthcoming Flex versions?
>
> Thanks,
>
> -- Frank
>
> --- In flexcoders@yahoogroups.com, Maciek Sakrejda <[EMAIL PROTECTED]> wrote:
> >
> > Frank,
> >
> > There's no .equals() in actionscript unless you implement it yourself.
> > Without hearing more about the context, it's hard to tell whether
> > Jitendra's data binding solution would work for this specific problem
> > (data binding would effectively set the list selection to an object that
> > is not in the list--I'm not sure what happens there), but you might run
> > into a need for .equals() further down the line. We did, and since all
> > of our VOs inherit from one VO base object, we just implement .equals()
> > in these as necessary. It seems rather horrifying that there's
> > no .equals() at first, but you don't really need it that often...
> >
> > --
> > Maciek Sakrejda
> > Truviso, Inc.
> > http://www.truviso.com
> >
> > -----Original Message-----
> > From: frank_sommers <[EMAIL PROTECTED]>
> > Reply-To: flexcoders@yahoogroups.com
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] Java-like equals() method?
> > Date: Sat, 11 Oct 2008 02:54:18 -0000
> >
> > Hi,
> >
> > I've been searching for a good solution to implementing object equality.
> > I'm familiar with
> > ObjectUtil, etc., but it still makes things harder than they should be.
> >
> > It may be best to illustrate this with an example. Suppose I have a
> > ComboBox with an
> > ArrayCollection as a data provider. The ArrayCollection is populated
> > with value objects
> > from the server, e.g., User objects. Suppose that I have a Task class,
> > and a Task may
> > have an assignedToUser property, which is a User instance. When the
> > someone selects a
> > Task (say, in a master-detail view), I would like the ComboBox to set
> > its selectedItem to
> > the user for the given Task, i.e., combBox.selectedItem =
> > myUser.assignedToUser.
> >
> > The problem is that no Task in the ComboBox's data provider and the
> > User's
> > assignedToUser property are ever equal using the == or === operators.
> >
> > So I would like to implement a custom equality for User, and have the
> > ComboBox use that
> > to set its selectedItem to the specified user. In Java, this is easily
> > done by overriding the
> > equals() and hashCode() methods of User.
> >
> > Any suggestions on how to achieve something similar in Flex would be
> > much appreciated.
> >
> > Thanks,
> >
> > -- Frank
> >
>
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Like the cut of my jib? Check out my Flex blog!

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]
:: http://flex.joshmcdonald.info/

Reply via email to