[Seaside] generating callback from ajax

Julian Fitzell jfitzell at gmail.com
Sat Sep 17 17:07:54 UTC 2011

Yes, I think you'll run into problems if you use the back button, open
multiple tabs, or start backtracking state.

As Johan says, AJAX callbacks are a bit weird because they operate
within an existing continuation. Some the likely changes in Seaside
3.1 may be of interest to you as the will expose the continuations
more easily within the callbacks - you would thus be able to access
the callback store for the current continuation.

I've also added pluggable continuations, which might actually be more
helpful to you, but I actually can't quite tell what you're trying to
accomplish here.


On Sat, Sep 17, 2011 at 5:13 PM, Johan Brichau <johan at inceptive.be> wrote:
> How are you registering the callback that will that call the #ajaxCallback method?
> I'm asking because I see no reason to have such a construction. If you are registering an ajax callback that is supposed to render something (html, script, json, …) Seaside provides you with an appropriate renderContext. In all kinds of callbacks, you can therefore access the callbacks dictionary without needing to 'reuse' an old canvas / rendercontext.
> As far as I understand it, if you are reusing the canvas of one render loop inside another loop (action or render callback), the url that is generated in your ajaxCallback method will contain an 'old' continuation key.
> It probably only works correctly because ajax callbacks operate inside the last continuation state and do not create a new continuation. As a result, the continuation key remains the same and the 'old' key is thus always the 'current' key. This will probably mean that you will not get strange state results.
> On 17 Sep 2011, at 16:31, Milan Mimica wrote:
>> I know I'm not supposed to reuse the canvas provided by
>> "WAComponent>>renderContentOn: html", but I am resusing it to generate
>> callbacks in ajax responses.
>> Something like this:
>> MyComponent>>renderContentOn: html
>> canvas := html.
>> ... rendering ...
>> ... registering callback ...
>> MyComponent>>ajaxCallback
>> | url |
>>  url := canvas actionUrl copy
>>               addField: (canvas callbacks store: (JSAjaxCallback on: [...]));
>>               yourself.
>>    self requestContext respond: [ :ret |
>>               ret     doNotCache;
>>                       contentType: (WAMimeType applicationJson
>>                               charset: self requestContext handler charSet).
>>               url asString jsonOn: ret stream].
>> It works. The question is: Is it bad?
>> --
>> Milan Mimica
>> http://sparklet.sf.net
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list