[Seaside] How did you solve the ajax & back browser button problem?

Johan Brichau johan at inceptive.be
Mon May 19 16:57:14 UTC 2014

Hi Sabine,

Aaaah... the joys of the back button server-side rendered ajax applications...

As Paul points out, if you use the ajaxifier library, there is a solution that uses the html5 history API [1].
The ajaxifier library transforms Seaside callbacks into browser ajax requests on the client side. However, this means that they are still executed as full page requests in Seaside itself.
If I remember correctly, it pushes the continuation key onto the state history stack. A back button press can then make a call to fetch the previous continuation.

It makes the use of ajax transparant, but it also defeats many of the use cases for it (imho).

So you are probably not using the ajaxifier library (neither am I) and you are writing the ajax calls yourself.
I'm afraid that means you have to implement a solution that fits your needs as well :-( You will have to determine what it means to 'go to the page before'. If it means 'going to the state before the last ajax call', then you are in for some work. 

I once tried to implement this (at esug 2012 in Gent actually) but I never finished it. Here is what I tried to do:

Seaside ajax callbacks are changing the state of the current continuation without copying the state and snapping off a new continuation. If you want to be able to go back to the previous state before the ajax callback, an ajax callback should first copy the session state (just as is done in a full page request) before execution. The key for that state should go in the history api (as in [1]). When a request for that state comes in, the entire page should be re-rendered using the saved state.

I think this should be able to get working using the abstractions available in Seaside and I would love to hack on that at ESUG this year. 
Unfortunately, promising anything before that is just not going to happen because of lack of time :-/


[1] http://html5doctor.com/history-api/

On 19 May 2014, at 14:23, Sabine Knöfel <sabine.knoefel at gmail.com> wrote:

> Hi,
> my application does much with ajax calls and because of this, my browser
> history is nearly empty.
> There are, indepently from pharo and seaside,  several solutions for this
> problem described in the web. 
> But after looking around for a while I want to ask how did (or how would)
> you solve this problem within pharo and seaside?
> I want that my users can click the back button and go to the "page before".
> Can I solve this with Seaside-REST? Which is the best way?
> Regards
> Sabine
> --
> View this message in context: http://forum.world.st/How-did-you-solve-the-ajax-back-browser-button-problem-tp4759490.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list