• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best Approach Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Approach Question


  • Subject: Re: Best Approach Question
  • From: David LeBer <email@hidden>
  • Date: Tue, 16 Mar 2004 13:57:40 -0500

On 16-Mar-04, at 12:44 PM, James Cicenia wrote:

Hello -

I am developing a wizard which has three pages with the usual
next and previous buttons. When I call this wizard from one of
my pages I will obviously instantiate a new object. I was doing this
on the first page constructor but realized that if they went back to that
page with the previous button it would create a new instance again.


So I figure that I would instantiate the object from the calling page.
There also needs to be created a new object which is related with
a one-one relationship. Since both objects are brand new will the
EO take care of the relationship ? Do I just simply use the
addObjectToBothSidesOfRelationship method?

Yes :-)

The simplest form is to have the action that calls your next component do something like this:

public Page2 goToPage2() {
	Page2 nextPage = (Page2)pageWithName("Page2);
	Session session = (Session)this.session();
	EOEditingContext ec = session.defaultEditingContext();
	EO1 eo1 = new EO1;
	EO2 eo2 = new EO2;
	ec.insertObject(eo1);
	ec.insertObject(eo2);
	eo1.addObjectToBothSidesOfRelationshipWithKey(eo2, "eo2s");
	nextPage.setEO1(eo1);
	return nextPage;
}

You can make it more elegant if you like, as Steve Stout recommends, In my case I like to use a set of factory classes.

;david

--
David LeBer
Codebase Software Systems
site:   http://www.codebase.ca
blog: http://david.codebase.ca
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Best Approach Question (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: Memory management
  • Next by Date: Re: Editing Context Question
  • Previous by thread: Re: Best Approach Question
  • Next by thread: Editing Context Question
  • Index(es):
    • Date
    • Thread