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
And I am trying to implement his recommendations about Page Inheritance.
First we have this diagram.
And this is the justification for doing that.
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 {
/**
* Editing Context
*/
protected EOEditingContext ec = null;
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
And this is the justification:
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.
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.
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?
Thanks in advanced.