[Seaside] Help needed for the Back button

Michel Bany m.bany at wanadoo.fr
Thu Jun 3 08:41:35 CEST 2004


Avi Bryant a écrit :

>
> On Jun 1, 2004, at 7:09 AM, Bany, Michel wrote:
>
>> Here is a link to a Seaside app http://mbany.ath.cx/seaside/go/Hanoi
>> where I have problems with the state of an algorithm object.
>> Press "Start game",
>> then do an explicit move from 1 to 2,
>> then press the browser Back button,
>> then move again from 1 to 2.
>> It reacts as if the Back button was not pressed.
>> What did I do wrong ?
>> Michel.
>
>
> Try registering the game object for backtracking (using 
> WASession>>registerObjectForBacktracking:).  That avoids using 
> WAStateHolder inside the model, and should be more effective than 
> wrapping the reference to the game inside a WAStateHolder
> (which only does anything if you switch game instances, not if you 
> modify the current one).
>
> That'll only work a shallow copy will capture all of the relevant 
> state of the HanoiGame; I haven't looked at your code deeply enough to 
> know if it will.

I believe I am starting understanding how the object backtracking is 
working. The HanoiGame object
is too complex and its state cannot be preserved by doing only a shallow 
copy. We would need a deeper
copy. I considered the idea of implementing #shallowCopy but I changed 
my mind because although
I would be able to snapshot a deeper copy, the restore would only do a 
shallow copy (as I understand it).

Then I had the idea to check how the Back button works for the store 
application. I discovered that it
does not work right either, because, here too, the WAStoreCart is too 
complex. It holds the items in a Bag
and would therefore need a deeper copy to completely preserve its state.
Try it:
Start the store app.
Click Browse
Click "Akagai"
Press Add To Cart
Press the Browser Back button
Press Add To Cart

In my opinion, the code in restoreObject:fromSnapshot: should be moved 
to Object>>restoreFromSnapshot:
so that everyone is able to re-implement a consistent pair of 
#shallowCopy/#restoreFromSnapshot: methods.

Michel.



More information about the Seaside mailing list