[Seaside] bug or misunderstanding?
ramon.leon at allresnet.com
Fri Apr 18 18:50:17 UTC 2008
> Top level component is this:
> renderContentOn: html
> | holder |
> html heading: 'test of callback'.
> html form: [
> html textInput callback: [:e | holder := e].
> html submitButton callback: [Transcript show: holder; cr]
> Why is "holder" nil here? I can see that my textinput
> callback is called first. Shouldn't both of the callbacks
> share the same reference to "holder"?
> Bug or my misunderstanding? Is there a fix or a workaround,
> or a better way to do this?
> This works fine if I make holder an instvar, by the way, but
> I don't want to do that as it complicates the example.
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
It's because Seaside calls fixCallbackTemps on callback blocks giving each
block it's own copy of locals so that you don't run into weird problems when
doing loops and expecting the block to act as a proper closure. Without
doing this, every reference to "each" in loop would end up referencing the
last item assigned to "each". As much as possible, I just avoid using temps
and state in render methods unless it's absolutely necessary.
More information about the seaside