A little Seaside extension

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

A little Seaside extension

Louis LaBrunda
Hi Seasiders,

I recently asked a question on a Seaside list 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 FitZell 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 posted a note on the Seaside list but haven't gotten any replies.  I'm posting it here to see what VA Smalltalkers think and to share the solution.

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

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/YUDpTO7dcyMJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.