[Seaside] Iterating through list - callback

Julian Fitzell jfitzell at gmail.com
Sun May 30 23:16:04 UTC 2010

Hi Jon,

It sounds like you're using an older Squeak image or VM without the
new closure support. For a very long time, Squeak has made do without
full closures. Most of the time, you won't notice a difference but
you've come across the case where you do. :) (The problem, if you're
interested, is that the blocks created in the loop are all sharing the
method context's variable slots rather than having their own).

The simplest solution is to move the code inside the loop (or at least
the part that creates new blocks) into a separate method:

rs := slotquery rset.
[rs next]
  whileTrue: [ self renderUser: (rs valueNamed: 'name') on: html ].

The other thing that should work is adding a call to #fixCallbackTemps
on the inner block (this is what Seaside does):

html anchor callback: [self deleteUser:user] fixCallbackTemps; with:' Delete'.

Or, make sure you have the Squeak 4.1 VM and image (or Pharo). Both
now have proper full closure support and your original code will
behave as you expected.


On Sun, May 30, 2010 at 10:59 PM,  <recursive68 at gmail.com> wrote:
> Hi,
> I'm trying to iterate through a resultset from a MySQL query and although
> it's displaying the users as required when I click on the anchor it always
> deletes the last user in the list rather than the one selected:
> rs := slotquery rset.
> [rs next]
> whileTrue:[
> user:= rs valueNamed: 'name'.
> html text: user.
> html anchor callback: [self deleteUser:user]; with:' Delete'.
> html break.
> ].
> It seems the anchor  callback always uses the last assignment to user, where
> am I going wrong ?
> Thanks
> jon
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list