Question about Section 12.2 of the Seaside book

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

Question about Section 12.2 of the Seaside book

Elliot Finley
Hello,

I've been going through the Seaside online book and so far everything has been intuitive and straightforward.  At the very end of section 12.2 (Example: Embedding an Editor) there is a note that says:

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.

In the context of section 11.5, ContactListView is 'call:'ing the editor and testing the return value to decide whether or not to save the changes.  This is very straightforward.  

In the context of section 12.2, IAddress is embedding the editor and thus it is not clear or intuitive where I would test the return value of the editor to decide whether or not to save the changes.  I'm sure this is an easy question for the season veterans, but I'm just not seeing it.

Thanks in advance for any help, pointers, etc...

Elliot

P.S. This is using the Seaside 3.0 One-click on a Macbook Pro (OS X 10.6.4).


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

Ramon Leon-5
On 10/21/2010 3:49 PM, Elliot Finley wrote:
> In the context of section 12.2, IAddress is embedding the editor and
> thus it is not clear or intuitive where I would test the return value of
> the editor to decide whether or not to save the changes.  I'm sure this
> is an easy question for the season veterans, but I'm just not seeing it.

See http://book.seaside.st/book/in-action/todo/embeddingchildren

Specifically the #onAnswer: block given to the component when it's created.

--
Ramon Leon
http://onsmalltalk.com
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

John McKeon
In reply to this post by Elliot Finley
Hi Elliot,
The editor is a form whose fields are bound to the object it is editing, and the submit button (whether the Cancel or Save button) will perform the form's input field callbacks first (see Section 10.1).
Hope this helps
John

On Thu, Oct 21, 2010 at 6:49 PM, Elliot Finley <[hidden email]> wrote:
Hello,

I've been going through the Seaside online book and so far everything has been intuitive and straightforward.  At the very end of section 12.2 (Example: Embedding an Editor) there is a note that says:

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.

In the context of section 11.5, ContactListView is 'call:'ing the editor and testing the return value to decide whether or not to save the changes.  This is very straightforward.  

In the context of section 12.2, IAddress is embedding the editor and thus it is not clear or intuitive where I would test the return value of the editor to decide whether or not to save the changes.  I'm sure this is an easy question for the season veterans, but I'm just not seeing it.

Thanks in advance for any help, pointers, etc...

Elliot

P.S. This is using the Seaside 3.0 One-click on a Macbook Pro (OS X 10.6.4).


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




--
http://john-mckeon.us

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

Elliot Finley
This means the editor needs to operate on a copy of the object.

On Thu, Oct 21, 2010 at 6:32 PM, John McKeon <[hidden email]> wrote:
Hi Elliot,
The editor is a form whose fields are bound to the object it is editing, and the submit button (whether the Cancel or Save button) will perform the form's input field callbacks first (see Section 10.1).
Hope this helps
John

On Thu, Oct 21, 2010 at 6:49 PM, Elliot Finley <[hidden email]> wrote:
Hello,

I've been going through the Seaside online book and so far everything has been intuitive and straightforward.  At the very end of section 12.2 (Example: Embedding an Editor) there is a note that says:

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.

In the context of section 11.5, ContactListView is 'call:'ing the editor and testing the return value to decide whether or not to save the changes.  This is very straightforward.  

In the context of section 12.2, IAddress is embedding the editor and thus it is not clear or intuitive where I would test the return value of the editor to decide whether or not to save the changes.  I'm sure this is an easy question for the season veterans, but I'm just not seeing it.

Thanks in advance for any help, pointers, etc...

Elliot

P.S. This is using the Seaside 3.0 One-click on a Macbook Pro (OS X 10.6.4).


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




--
http://john-mckeon.us

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



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

Elliot Finley
In reply to this post by Ramon Leon-5
On Thu, Oct 21, 2010 at 5:31 PM, Ramon Leon <[hidden email]> wrote:
On 10/21/2010 3:49 PM, Elliot Finley wrote:
In the context of section 12.2, IAddress is embedding the editor and
thus it is not clear or intuitive where I would test the return value of
the editor to decide whether or not to save the changes.  I'm sure this
is an easy question for the season veterans, but I'm just not seeing it.

See http://book.seaside.st/book/in-action/todo/embeddingchildren

Specifically the #onAnswer: block given to the component when it's created.

Ramon,

Thanks for this.  I was able to get it working with this information.  My next question is:  How do we correct the book?  It references a previous section of the book that doesn't have the correct info in this context.

Elliot


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

John McKeon
In reply to this post by Elliot Finley


On Fri, Oct 22, 2010 at 8:31 PM, Elliot Finley <[hidden email]> wrote:
This means the editor needs to operate on a copy of the object.

Yes, and the only place you can put code to deal with the copy is in the button callbacks. In this configuration though, answer: is of no use. You would need to do something else...  

On Thu, Oct 21, 2010 at 6:32 PM, John McKeon <[hidden email]> wrote:
Hi Elliot,
The editor is a form whose fields are bound to the object it is editing, and the submit button (whether the Cancel or Save button) will perform the form's input field callbacks first (see Section 10.1).
Hope this helps
John

On Thu, Oct 21, 2010 at 6:49 PM, Elliot Finley <[hidden email]> wrote:
Hello,

I've been going through the Seaside online book and so far everything has been intuitive and straightforward.  At the very end of section 12.2 (Example: Embedding an Editor) there is a note that says:

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.

In the context of section 11.5, ContactListView is 'call:'ing the editor and testing the return value to decide whether or not to save the changes.  This is very straightforward.  

In the context of section 12.2, IAddress is embedding the editor and thus it is not clear or intuitive where I would test the return value of the editor to decide whether or not to save the changes.  I'm sure this is an easy question for the season veterans, but I'm just not seeing it.

Thanks in advance for any help, pointers, etc...

Elliot

P.S. This is using the Seaside 3.0 One-click on a Macbook Pro (OS X 10.6.4).


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




--
http://john-mckeon.us

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



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




--
http://john-mckeon.us

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

Elliot Finley
On Fri, Oct 22, 2010 at 6:37 PM, John McKeon <[hidden email]> wrote:


On Fri, Oct 22, 2010 at 8:31 PM, Elliot Finley <[hidden email]> wrote:
This means the editor needs to operate on a copy of the object.

Yes, and the only place you can put code to deal with the copy is in the button callbacks. In this configuration though, answer: is of no use. You would need to do something else...  


This is how I did it.  I'm a Smalltalk beginner, so there is probably a much better way.
 
 IAddress>>initialize
super initialize.
editor := ContactView new.
self editContact: self contacts first.
editor onAnswer: [ :answer | answer ifTrue: [ self save ] ifFalse: [ self cancel ] ]

IAddress>>editContact: aContact
contactCurrentlyBeingEdited := aContact.
editor contact: aContact copy.

IAddress>>save
Contact removeContact: contactCurrentlyBeingEdited; addContact: editor contact

IAddress>>cancel
self editContact: contactCurrentlyBeingEdited.


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

John McKeon
Wow I stand corrected. I had no idea you could answer: from a component that hadn't been called. You learn something new every day.
Back to reading....

On Fri, Oct 22, 2010 at 9:02 PM, Elliot Finley <[hidden email]> wrote:
On Fri, Oct 22, 2010 at 6:37 PM, John McKeon <[hidden email]> wrote:


On Fri, Oct 22, 2010 at 8:31 PM, Elliot Finley <[hidden email]> wrote:
This means the editor needs to operate on a copy of the object.

Yes, and the only place you can put code to deal with the copy is in the button callbacks. In this configuration though, answer: is of no use. You would need to do something else...  


This is how I did it.  I'm a Smalltalk beginner, so there is probably a much better way.
 
 IAddress>>initialize
super initialize.
editor := ContactView new.
self editContact: self contacts first.
editor onAnswer: [ :answer | answer ifTrue: [ self save ] ifFalse: [ self cancel ] ]

IAddress>>editContact: aContact
contactCurrentlyBeingEdited := aContact.
editor contact: aContact copy.

IAddress>>save
Contact removeContact: contactCurrentlyBeingEdited; addContact: editor contact

IAddress>>cancel
self editContact: contactCurrentlyBeingEdited.


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




--
http://john-mckeon.us

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Question about Section 12.2 of the Seaside book

Ramon Leon-5
In reply to this post by Elliot Finley
On 10/22/2010 5:34 PM, Elliot Finley wrote:
> Thanks for this.  I was able to get it working with this information.
>   My next question is:  How do we correct the book?  It references a
> previous section of the book that doesn't have the correct info in this
> context.
>
> Elliot

Put your notes at the bottom of that page in the book in case anyone
else trips up on this, and then perhaps contact one of the authors to
see if they'll make a correction.

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