[Seaside] liveAction using existing method

Avi Bryant avi.bryant at gmail.com
Thu Jun 30 02:58:48 CEST 2005


On 6/30/05, William E Harford <seaside at harford.org> wrote:

> Now it updates the right div but for some reason row always contains a
> Dictionary representing the last row. It is most likely a
> misunderstanding on my part of how SmallTalk blocks work (I am new to
> SmallTalk and I am never going back) but...

Well, it's basically a bug with how blocks were traditionally
implemented in Smalltalk - some newer Smalltalks have fixed it, but
Squeak uses the old way (the technical phrase is that Squeak doesn't
have "full block closures").  The bug is that there's only one
variable frame shared by all invocations of a particular block, and so
if you're saving a block inside a loop, rather than capturing the
current value of any loop variables, you end up capturing the last
one.

The workaround is to send #fixTemps to any such blocks you're saving,
which will explicitly copy the variable frame for you.  Seaside does
this automatically for any normal callbacks, but I clearly forgot to
do it for live callbacks.  The quick fix would be this:

html anchorWithAction: []
   liveAction:[:h |
   self showPatient: (row at: 'ionumber') .
   self renderPatientOn: h.
] fixTemps
 text: (row at: 'lastname') .

Cheers,
Avi


More information about the Seaside mailing list