[Seaside] Generated links (anchor -> callback)

Dale Henrichs dale.henrichs at gemstone.com
Sun Jul 5 20:35:22 UTC 2009


Mark,

You've tripped over a block bug in GemStone. In GemStone the temp variable in the block (index) is shared across block invocations, so the value that the block was called with is not preserved when the callback is invoked.

There's a workaround, but I'm at the beach and don't have ready access to a stone (and I don't recall the details), so perhaps James Foster (or another GemStoner) can chime in...

Dale

----- "Mark Ross" <mark at markross.de> wrote:

| Hi seaside list!
| 
| I'm roughly new in developing seaside. Trying out some seaside
| development.
| 
| I'm using:
| GemStone/S 64 Bit
| 2.3.1 Build: gss64_2_3_x_branch-20643
| Thu Dec  4 11:33:32 2008
| 
| with GemTools 2.3.1
| 
| I would like create links on my page - with generated URLS, which have
| the
| value of the index from render time.
| 
| I try by using something like this:
| 
| initialize
|         super initialize.
|         self value: 0
| 
| renderContentOn: canvas
| 
| canvas text: self value.
| 
|    1 to: 10 do: [ :index |
|        canvas anchor
|           callback:[ self value: index  ];
|                  with: index.
|        html space ].
| 
| -> The value is everytime clicking on a link '10' - which I would
| understand, if i didn't read the tutorial on the seaside.st site:
| 
| -----snip -----
| renderContentOn: html
|    1 to: 10 do: [ :index |
|        html anchor
|           callback: [ index inspect ];
|           with: index.
|        html space ]
| 
| It will generate a series of links, labelled from 1 to 10. Because
| the
| action blocks capture the current value of the i variable, each one
| will
| have a distinct callback: clicking on the "1" link will evaluate 1
| inspect, on the "2" link will evaluate 2 inspect, and so on. The
| block
| closure is being used to maintain all of the interesting state for
| the
| link.
| -----snap-----
| 
| Please, can somebody help me out finding my mistake?
| 
| Best regards
| 
| Mark
| 
| 
| _______________________________________________
| seaside mailing list
| seaside at lists.squeakfoundation.org
| http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list