A solution for blocked (locked) updates and the "back" button

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

A solution for blocked (locked) updates and the "back" button

Louis LaBrunda
Hi Seasiders,

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
cancelButton.

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
signaled.

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.

Lou

I subclassed #WAHiddenInputTag with: #WAEarlyHiddenInputTag and overrode
callback: with:

callback: aBlock
        self name: (self storeCallback: (WAEarlyValueCallback on: aBlock))

where WAEarlyValueCallback is a subclass of #WAValueCallback of which I
overrode #evaluateWithArgument: and #priority as follows:

evaluateWithArgument: anObject
        (block valueWithPossibleArguments: (Array with: anObject)) ifFalse:
[WARenderNotification signal].

priority
        ^ -3

To wrap things up I extended #WARenderCanvas with:

earlyHiddenInput
        ^ self brush: WAEarlyHiddenInputTag new

-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside