Re: Chuck Hill's quite good Practices, WOWODC 08
Re: Chuck Hill's quite good Practices, WOWODC 08
- Subject: Re: Chuck Hill's quite good Practices, WOWODC 08
- From: Chuck Hill <email@hidden>
- Date: Tue, 21 Jul 2009 17:10:04 -0700
Hi Miguel,
On Jul 21, 2009, at 4:53 PM, Miguel Angel Torres Avila wrote:
Hi guys,
I am staring a new project and I want to use Wonder and try to
implement Chuck Hill's recommended best practices.
I have watched a lot of times (almost 10 times) the screencast
http://www.wocommunity.org/podcasts/WOWODC08_BestPratices.mp4
And I am trying to implement his recommendations about Page
Inheritance.
First we have this diagram.
<Picture 2.png>
And this is the justification for doing that.
<Picture 3.png>
At this time I am focusing on the editingContext method.
I have created a Java Class called CommonPage:
import com.webobjects.appserver.WOContext;
import com.webobjects.eocontrol.EOEditingContext;
import er.extensions.components.ERXComponent;
import er.extensions.eof.ERXEC;
@SuppressWarnings("serial")
public class CommonPage extends ERXComponent {
/**
*EditingContext
*/
protected EOEditingContext ec = null;
I'd make that private so that use of editingContext() is enforced.
public CommonPage(WOContext context) {
super(context);
ec = ERXEC.newEditingContext();
}
public EOEditingContext editingContext(){
return ec;
}
}
As you can see it is extending from ERXComponent, I just added an
Editing Context an a method to get it.
Next, Chuck talks about the importance of creating a
CommonComponent Class
<Picture 1.png>
And this is the justification:
<Picture 4.png>
As far as I can understand (English is not my natural language) the
idea is to create a method editingContext() that returns the Page
editing Context.
I am confused at this point. Based on the diagram CommonComponent
inherits from CommonPage so, it has its own editing context because
CommonPage creates a new one on its constructor.
Cough. Yes. Well. er. The diagram is wrong. Congratulations, you
are the only one to have noticed this! Including me... :-(
CommonPage and CommonComponent should have the same super-class.
You can use ERXComponent for this or subclass ERXComponent and make
your own custom super class.
public CommonPage(WOContext context) {
super(context);
ec = ERXEC.newEditingContext();
}
I think the idea of a CommonComponent is to use it on every
"subComponent" of my application, and the idea of a editingContext()
method on the CommonComponent is to get the editing Context of the
Page that is wrapping the SubComponent, in other words, the
SubComponent's father.
That is correct.
In all my projects, before using Wonder and before trying to
implement Chuck's best practices I used to create a new
EditingContext in my principal Component and pass it to the
subcomponent through bindings. That way the main component (Page)
has the editinContext control.
I just want to know if my interpretation of the screencast is
correct or I am misunderstanding it. If I am understanding, could
someone explain me how the editingContext() method in the
ComonComponent would work?
Your English is fine. It is my diagrams that need help.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Learn WO at WOWODC'09 East in Montréal this August!
http://www.wocommunity.org/wowodc09/east
http://arstechnica.com/apple/news/2009/07/webobjects-sliced-from-106but-prognosis-of-death-premature.ars
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden