[Seaside] generating callback from ajax
johan at inceptive.be
Sat Sep 17 16:13:02 UTC 2011
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 ...
> | url |
> url := canvas actionUrl copy
> addField: (canvas callbacks store: (JSAjaxCallback on: [...]));
> 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
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside