[Seaside] Form processing question..

Rick Flower rickf at ca-flower.com
Fri Jul 28 17:40:57 UTC 2006


Dan Shafer wrote:
> Pray, tell us how! This is an issue I'm sure to run into as well.

Dan..

In my particular case, with code that was posted to this list back in 
Feb/March of this year (look for threads with my name in them), my top 
level application class has the concept of the "currentWidget" and to 
solve this problem, I added a "lastWidget" object as well.  The 
currentWidget always refers to the page about to be painted (think of 
that as the newly selected page), and the "lastWidget" was the last page 
to be painted (about to go out of scope if you will).  Using this 
concept and having all of my widgets inherit from a (mostly) empty base 
class called MSWBase, I've got the following that all widgets inherit 
(and can override if needed):

MSWBase>>abortOperation
    "Abort any existing operation going on if the user decides to render 
a different object (e.g. visit a different page)"
    "In this case, you should override this in any derived classes to do 
what you need."

While this does nothing for most objects, any object that does need it 
can easily override it such as in my contact page widget, which looks 
like the following :

MSWContact>>abortOperation
    "Abort any existing operation going on if the user decides to render 
a different object (e.g. visit a different page)"
     validationDict keysDo: [:key | validationDict removeKey: key].
     (self userProxy) rollBack.

In this case, I'm rolling back my proxy to forget any modifications made 
  to my proxy object -- I've got a modified version of WAModelProxy I'm 
using (thanks to Martin Laubach for the suggestion and code hints), and 
ditching any validation errors from my validation dictionary (filled in 
by my form validator).

Anyway, got a bit off track there.. Let's see.. In my menu class 
(MSWMenu), I've got code like the following:

html listItem with:
[
    html anchor callback:
    [
       (parent lastWidget) abortOperation.
       self contactWidget
    ];
    text: 'Update Contact Info'
]

If you do this for every link in your menu, then each widget has a 
chance to do any sort of aborting needed to cleanup whatever it was 
doing.  In this case, if the user was in the contact page and pressed 
the contact page link again, all of his changes would be tossed out as 
part of the abortOperation method call above.

Hope this helps (and more importantly makes sense!)..

-- Rick


More information about the Seaside mailing list