[Seaside] A solution for blocked (locked) updates and the "back"
Lou at Keystone-Software.com
Tue Jun 28 19:47:08 UTC 2011
I recently asked a question about canceling a request before the values of
the form fields are applied to an object and stop them from being applied,
so I wouldn't need a copy of the original object. Julian suggested I use a
cancelButton, it was exactly what I was looking for at least for cancel
buttons (thanks Julian).
I then wanted to take things a little farther and cancel updates to objects
when the object is locked for some reason or if the user was playing around
with the web browser back button. I came up with a solution similar to the
I created two subclasses and an extension that I detail below. They allow
me to set a hidden value whose callback gets processed before all other
value callbacks. The callback is a one argument block that receives the
hidden value. The callback can check the hidden value against a saved
value to see if the "back" button was used or make other tests to determine
if it is okay to apply the form values to whatever objects they are
connected to. The callback block returns true if processing should
continue and false if not. To stop processing WARenderNotification is
I'm happy with this solution but would like to know if:
1) It really makes sense? I'm not doing anything against Seaside rules.
2) There is a better way?
If this seems like a good solution, the Seaside developers are welcome to
it. I'm not married to the names of the subclasses or the
#earlyHiddenInput method name. It is somewhat short for
early-response-hidden-input, so I am open to suggestions.
I subclassed #WAHiddenInputTag with: #WAEarlyHiddenInputTag and overrode
self name: (self storeCallback: (WAEarlyValueCallback on: aBlock))
where WAEarlyValueCallback is a subclass of #WAValueCallback of which I
overrode #evaluateWithArgument: and #priority as follows:
(block valueWithPossibleArguments: (Array with: anObject)) ifFalse:
To wrap things up I extended #WARenderCanvas with:
^ self brush: WAEarlyHiddenInputTag new
Keystone Software Corp.
mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com
More information about the seaside