[Seaside] Re: I have a possible solution to the puzzle at end
of Chapter 12.2
intrader.intrader at gmail.com
Wed Jun 15 18:20:28 UTC 2011
Lukas Renggli <renggli <at> gmail.com> writes:
> Hard to tell from the context given (The code looks suspicious to
> assign multiple onAnswer: handler). The cancel button works fine as
> long as the form is not submitted multiple times, such as for
> validation. The easiest and most stable solution is to edit a copy of
> the contact and to replace it in the collection on success.
Thanks Lukas for your comment.
Sorry you found the posting to have lack of context. I am referencing Chapter
12.2 of Dynamic Web Development with Seaside. The end of the chapter states:
"Our simple implementation of IAddress>>editContact: will save changes even when
you press cancel. See Section 11.5 to understand how you can change this.".
I have coded my interpretation of what Chapter 11.5 means as follows:
| copy |
copy := aContact copy.
(editor contact: copy) onAnswer: [ :answer |
"copy has been updated - keep update if Save"
Contact removeContact: aContact; addContact: copy.
"Problem: a reclick on Save aborts because contact is not in
As you suggest the above code should replace the contact with the copy. I do not
yet have the proper coding for replacing the contact.
The solution suggested by Joachim uses `self handleAnswer: false`. This works. I
am seeking comment as to the approach and validity of relying on priority of the
cancel callback and use of #handleAnswer.
More information about the seaside