[Seaside] Problem with callback blocks sharing context using
closure image
Johan Brichau
johan at inceptive.be
Mon Nov 1 06:27:25 UTC 2010
As bob & levente point out, it's because all callback blocks share the same scope with the same variable 'index'. But I think the following might be a quicker fix:
| index |
index := 1.
8 timesRepeat: [
aRenderer tableRow: [
5 timesRepeat: [
aRenderer tableData: [
|current |
current := index.
aRenderer anchor
callback: [ self callbackFor: current ];
with: 'image link'.
index := index + 1.
] ] ] ].
On 01 Nov 2010, at 02:41, Hernán Morales Durand <hernan.morales at gmail.com> wrote:
> Hi all,
>
> I'm experimenting different behavior between Seaside 2.8 and 3.0
> regarding parameters passed in callback blocks. Attached there is code
> to test in both platforms (just click in any of the first 8 links),
> the problem is in the variable index in the #callback: of the
> following code
>
>>> renderBlabla
> | index |
> index := 1.
> 8 timesRepeat: [
> aRenderer tableRow: [
> 5 timesRepeat: [
> aRenderer tableData: [
> aRenderer anchor
> callback: [ self callbackFor: index ];
> with: 'image link'.
> index := index + 1.
> ] ] ] ].
>
> In Seaside 2.8 after clicking the link 3 for example, the
> #callbackFor: method received 3 as parameter.
> In Seaside 3.0 #callbackFor: receive 41.
>
> I would like to preserve the parameter value configured in the
> rendering phase, any suggestion how to do that in Seaside 3? (Using
> PharoVM 4.0.2 12/4/2010 and Pharo1.1rc2 #11400)
> Cheers,
>
> --
> Hernán Morales
> Information Technology Manager,
> Institute of Veterinary Genetics.
> National Scientific and Technical Research Council (CONICET).
> La Plata (1900), Buenos Aires, Argentina.
> Telephone: +54 (0221) 421-1799.
> Internal: 422
> Fax: 425-7980 or 421-1799.
> <TestCallbackIndex-Core (Seaside 3).st>
> <TestCallbackIndex-Core (Seaside 28).st>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20101101/9d7605fc/attachment.htm
More information about the seaside
mailing list