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. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside TestCallbackIndex-Core (Seaside 3).st (3K) Download Attachment TestCallbackIndex-Core (Seaside 28).st (3K) Download Attachment |
On Mon, 1 Nov 2010, Hernán Morales Durand 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) send #fixTemps to the callback block. Levente > 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. > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Levente,
I'm actually using an image with closure support, at least the orange test answers 'orange' | blockArray dataArray | blockArray := Array new: 5. dataArray := #( 'Apple' 'Orange' 'Grape' 'Lemon' 'Kiwi'). 1 to: blockArray size do: [ :index | blockArray at: index put: [ dataArray at: index ] ]. ^(blockArray at: 2) value Cheers, 2010/11/1 Levente Uzonyi <[hidden email]>: > On Mon, 1 Nov 2010, Hernán Morales Durand wrote: >> >> 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) > > Use an image with support for closures. Or if that's not possible, then send > #fixTemps to the callback block. > > > Levente > >> 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. > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Levente Uzonyi-2
Actually, that would not work as written in a
closure image. To make it work in closure image, you could
write something like:
... aRenderer anchor callback: (makeCallBackWith: index ); ...And then write a method makeCallBackWith: n ^[self callbackFor: n]In a non-closure image, it would work as written since fixCallbackTemps would have been sent automatically. Cheers, Bob On 10/31/10 9:52 PM, Levente Uzonyi wrote: On Mon, 1 Nov 2010, Hernán Morales Durand wrote: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by hernanmd
On Mon, 1 Nov 2010, Hernán Morales Durand wrote:
> Hi Levente, > > I'm actually using an image with closure support, at least the orange > test answers 'orange' > > | blockArray dataArray | > blockArray := Array new: 5. > dataArray := #( 'Apple' 'Orange' 'Grape' 'Lemon' 'Kiwi'). > 1 to: blockArray size do: [ :index | > blockArray > at: index > put: [ dataArray at: index ] ]. > ^(blockArray at: 2) value recompile their methods. Something like this should do it: BlockContext allInstancesDo: [ :each | | method | method := each method. method methodClass recompile: method selector ]. Levente > > Cheers, > > 2010/11/1 Levente Uzonyi <[hidden email]>: >> On Mon, 1 Nov 2010, Hernán Morales Durand wrote: >>> >>> 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) >> >> Use an image with support for closures. Or if that's not possible, then send >> #fixTemps to the callback block. >> >> >> Levente >> >>> 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. >> >> _______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Bob Arning
On 10/31/10 10:16 PM, Bob Arning wrote: > callback: (makeCallBackWith: index ); Well, obviously that would be callback: (self makeCallBackWith: index ); _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Bob Arning
On Sun, 31 Oct 2010, Bob Arning wrote:
> Actually, that would not work as written in a closure image. To make it work > in closure image, you could write something like: > > ... > aRenderer anchor > callback: (makeCallBackWith: index ); > ... > > And then write a method > > makeCallBackWith: n > ^[self callbackFor: n] > > > In a non-closure image, it would work as written since fixCallbackTemps would > have been sent automatically. Levente > > Cheers, > Bob > > On 10/31/10 9:52 PM, Levente Uzonyi wrote: >> On Mon, 1 Nov 2010, Hernán Morales Durand 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) >> >> Use an image with support for closures. Or if that's not possible, then >> send #fixTemps to the callback block. >> >> >> Levente >> >>> 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. >>> >> >> _______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by hernanmd
On Mon, 1 Nov 2010, Hernán Morales Durand wrote:
> Hi Levente, > > I'm actually using an image with closure support, at least the orange > test answers 'orange' > > | blockArray dataArray | > blockArray := Array new: 5. > dataArray := #( 'Apple' 'Orange' 'Grape' 'Lemon' 'Kiwi'). > 1 to: blockArray size do: [ :index | > blockArray > at: index > put: [ dataArray at: index ] ]. > ^(blockArray at: 2) value the value of index changes. Levente > > Cheers, > > 2010/11/1 Levente Uzonyi <[hidden email]>: >> On Mon, 1 Nov 2010, Hernán Morales Durand wrote: >>> >>> 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) >> >> Use an image with support for closures. Or if that's not possible, then send >> #fixTemps to the callback block. >> >> >> Levente >> >>> 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. >> >> _______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Levente Uzonyi-2
2010/11/1 Levente Uzonyi <[hidden email]>:
> On Sun, 31 Oct 2010, Bob Arning wrote: > >> >> In a non-closure image, it would work as written since fixCallbackTemps >> would have been sent automatically. > > Argh. That's right, maybe it's time for me to get some sleep. :) > > For me too, thanks Bob and Levente. Cheers, Hernán > Levente > >> >> Cheers, >> Bob >> >> On 10/31/10 9:52 PM, Levente Uzonyi wrote: >>> >>> On Mon, 1 Nov 2010, Hernán Morales Durand 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) >>> >>> Use an image with support for closures. Or if that's not possible, then >>> send #fixTemps to the callback block. >>> >>> >>> Levente >>> >>>> 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. >>>> >>> >>> _______________________________________________ >>> seaside mailing list >>> [hidden email] >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > -- 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. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by hernanmd
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. ] ] ] ].
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |