Excellent, thanks!

Happy Kjetil

On May 27, 6:00 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> It does now.
>
> KeyedMapper had an equals method that "does the right thing".  I added
> hashCode and KeyedMappers should play well in HashMaps.
>
> On Wed, May 27, 2009 at 8:52 AM, Derek Chen-Becker 
> <dchenbec...@gmail.com>wrote:
>
>
>
> > AFAIK, Mapper doesn't define equality. You have to do that yourself as you
> > would for any other Scala/Java class by overriding equals and hashcode.
> > Using a Set (HashSet, specifically) seems like a pretty efficient way of
> > doing this, although there may be a better way depending on your usage.
>
> > Derek
>
> > On Wed, May 27, 2009 at 1:49 AM, valstadsve <valstad...@gmail.com> wrote:
>
> >> Long time reader, first time poster.
>
> >> Also first time liftweb developer. I have an app that loads rows from
> >> db using the Mapper framework, and displays them with a checkbox each.
> >> I track which objects are checked by storing them in a collection. To
> >> find the value of a checkbox (first argument to ajaxCheckbox), I do a
> >> lookup to see if the respective object is in the collection.
>
> >> I have tried two collections for this purpose, and only one of them
> >> works: (Names have been changed to protect... well, me)
>
> >> 1) Store mapped objects in a Set. This typically leads to:
>
> >> "check" -> ajaxCheckbox(coll.contains(a), v => { if (coll.contains(a))
> >> { // And so forth
>
> >> 2) Store mapped objects in a Map, using their id (a Long) as key. This
> >> usually ends in:
>
> >> "check" -> ajaxCheckbox(coll.contains(a.id), v => { if ( coll.contains
> >> (a.id)) { // And so forth and so forth
>
> >> As you might suspect from the subject of this post, only the second
> >> strategy works as expected. Comparing id's  is obviously more
> >> reliable. Using sets and relying on object identity instead, the
> >> checked objects render unchecked (and this is somewhat disturbing)
> >> MOST of the time. My guess is there is some object management going on
> >> behind the scenes, so that different requests deal with different
> >> instances for the same rows. However, the equals/hashCode regime of
> >> the Mother Platform _is_ supposed to resolve such things for
> >> collections ...
>
> >> So, being all new to this, I have several questions:
>
> >> 1) Should object identity work for subclasses of Mapper and friends?
> >> I.e. is this a bug?
>
> >> 2) Or am I expected to implement equality myself?
>
> >> 3) Are there better ways to track a long list of checkboxes? I have
> >> noticed that GUI/network lag and asynchrony, the (first) a in ajax,
> >> may produce twinkling checkboxes after a flurry of clicks...
>
> >> 4) Somewhat more far-fetched: Are collections in scala (gulp) not
> >> using equals/hashCode?
>
> >> Other than that, I am impressed with liftweb and find it an excellent
> >> introduction to Scala. Books are on order, too!
>
> >> Kjetil
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to