On Jul 21, 2009, at 5:34 PM, Chuck Hill wrote:

For components that you will use on CommonPage, you will sub-class CustomComponent as CommonComponent and implement editingContext() as:


public EOEditingContext editingContext(){
                return ((CommonPage)context().page()).editingContext();
}


Or, you can allow for components to possibly have their own editing context (with more than one EC on a page) and implement it like this:

public EOEditingContext editingContext(){
                return ((CustomComponent)parent()).editingContext();
}


I've used another approach and now I'd be interested to know if I'd be branded a fool for it. :-) Since my sub-components often have an EO passed to them via a binding, I often set the sub-component's editing context like this:

public EOEditingContext editingContext() {
        if(_editingContext == null) {
                _editingContext = passedEO().editingContext();
        }
        return _editingContext;
}

My thought was that I then knew for sure that my subcomponent was using the same ec as the parent.

These topics are awesome. Thanks Chuck!!

Tim
UCLA GSE&IS
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to