Kieran,

Agreed - the reason these suggestions were made is because he specifically stated that it's too late to change.

Ken

On May 3, 2006, at 9:57 AM, Kieran Kelleher wrote:

Stop! ...... here is the easy way...... ;-)

As per Apple WWDC sessions .... NEVER, EVER use the page constructor for creating EOEnterpriseObjects (or anything else for that matter). Use lazy initialization to create, fetch and pull in data "as required, on demand". Then you don't ever have to consider the order or sequence of events.

For example:

protected EOEnterpriseObject _myObject;

public EOEnterpriseObject myObject() {
        if ( _myObject == null ) {
_myObject = EOUtilities.createAndInsertInstance( ec, "entity_name" );
        }
        return _myObject;
}

Then it never matters what the user does with the page. If the object is not created, it will get created once the first time the getter method is called.

See this for more info:
http://david.codebase.ca/?p=75

HTH

-Kieran
________________________________________________________________
Blog: http://webobjects.webhop.org/


On May 2, 2006, at 8:48 PM, WebObjects wrote:

I've found an error in my coding style - too late in this project though. I use EOUtilities.createAndInsertInstance in a constructor for a page, and as
a result 'refresh' and 'back' have become my enemies.

How can I iterated over the unsaved objects in an EditingContext (ec), test their validity (ie. if ItemAt(0).getSomeValue() == null, etc) and delete
them from the ec prior to .saveChanges()  ?

Many thanks for ec insight!

-Bill


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists% 40mac.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/lists% 40anderhome.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to