[Seaside] Seaside sessions and ajax

Lukas Renggli renggli at gmail.com
Fri May 18 19:38:02 UTC 2007


> so, i can add #onFailure: handler for my updater ?

Yes, that's the idea.

> can you please point to small code snippet using this.

You can find the full documentation here:

	http://www.prototypejs.org/api/ajax/options

For example the counter application could be modified to look like:

	html anchor
		onClick: (html updater
			id: id;
			onFailure: (SUScript new alert: 'Ouch, the session is gone');
			callback: [ :render | self increase; renderCountOn: render ]);
		with: '++'.

> Im asking
> because its pretty hard to express some meaningfull javascript
> statements with current SUScript interface.
> For example, for generating a simple javascript
> if (...) { statements}  statements
> i have a following horror code in smalltalk:

Yes, that looks ugly. I have problems to understand, but I suspect ...

> I think this must be changed to more convenient form for generating a
> scripts by server.

Scriptaculous is not ment for that, but to interface with existing
Javascript code. I suggest that you write your functionality in an
external file and call it from the Scriptaculous tools. They are
designed to do that, not to write whole scripts.

> And if you know how, please tell me how i can set a default OnFailure
> handler in ajax, because putting onFailure: everywhere is too
> excessive.

You can set that on a per-handler bases, but pleas study the Protoypes
and script.aculo.us documentation for the details.

> I just need the seaside generate new continuation for Ajax requests.
> Backtracking a javascript actions seem pointless to me.

I don't want to backtrack Ajax requests, but to avoid that full
requests destroy what the Ajax requests have changed.

> About possible solution: suppose we already having a seaside
> generating new continuation for each Ajax request.
> Then on any answer we need to get new continuation id. And use this
> new id for browser navigation. It means that all anchor/forms must use
> this new id.
> This can be done by changing the Href generation in seaside. Instead
> of putting static _s,_k values, we need to put in all our Href-s a
> call to javascript function, which composes requests based on current
> _s, _k values received from last Ajax update request (or use initial
> values if there was none of them).

I am sure a lot of people don't want that. We generally try to keep
Seaside as Javascript free as possible. I know of many applications
that are supposed to run even without Javascript enabled.

I don't think that introducing new continuations solves the problem,
because it is not the ajax request that screws up the states but the
previous rendering request.

> All what i need to have is, when user navigates via link, to preserve
> the WAStateHolder values modified by Ajax requests invoked by some
> user actions on page. Currently, seaside ignoring these changes and
> reloads them from point when page was first loaded.

Yes, this is the point on the todo list for 2.8. The trick would be to
let the Ajax requests update the states of the last full rendering
request, however I didn't found a nice way to gasp that reference yet.

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch


More information about the seaside mailing list