Re: Components on a page question...
Re: Components on a page question...
- Subject: Re: Components on a page question...
- From: Jonathan Rochkind <email@hidden>
- Date: Mon, 29 Mar 2004 15:54:35 -0600
At 3:39 PM -0600 3/29/04, James Cicenia wrote:
However, it has made me rethink my work... I have always subclassed my
pages from a the master Page and had put all my code in there. But now
you have me thinking that that would be inefficient just keeping the
code within
the children only.. Well,, deadlines are looming so re-factoring
will have to be
done for version 1.1.
I don't know if it's an issue of efficient vs inefficient. It's an
issue of good design. Which I suppose has implications on
efficiency, but the primary thing here is design.
But I'm confused as to why you were making your partial pages
subclasses of their parent page in the first place. What purpose
were you trying to achieve here? In general, a subcomponent should,
of course, be useable in _multiple_ parent pages, and of course it
can't be a sub-class of all of them. There's no multiple inheritance
in Java (and this is largely a good thing). If you thought you _had_
to do this, or it was standard---that's not so. If you thought that
iVar state was somehow shared by all of these components because of
the inheritance hiearchy---that's certainly not so either.
I can't think of any good reason, in general, to have partial
components subclass the parent component they will exist in. But
that doesn't mean there aren't any good reasons that I haven't
thought of. It depends on what you were trying to achieve here.
But yeah, if you're on deadline, and It Ain't Broke, then Don't Fix It.
--Jonathan
-James Cicenia
On Mar 29, 2004, at 10:51 AM, Jonathan Rochkind wrote:
At 10:05 AM -0600 3/27/04, James Cicenia wrote:
Hello -
I have a WebObjects page that I built with multiple components
so that WOBuilder would have an easier time.
Say I have a Page with 3 components nested in it..
Page
Page1
Page2
Page3
I subclassed Page1, Page2, Page3 from Page.
Okay, to begin with this is an unusual design.
All my objects, initializations
are in Page. When it builds the page will Page1,2&3 void out my objects?
You're getting confused. Page1, Page2, Page3 and Page are all
distinct seperate objects. The fact that all the subcompobnents
subclass Page doesn't change anything; you still have four
different objects here. They do not share any state. Each has it's
own copies of all iVars. If you want these components to share
state, you need to pass objects from Page into the sub-components
via bindings. And it probably isn't neccesary and is probably not
a good idea to have these subcomponents sub-class the Page
class---at least if the only reason you were doing that was to try
and get them to share state, which that won't accomplish anyway.
If you already do have bindings, let us know what they are. The
bindings could be implicated in your values changing when you don't
expect them to also. The default WO framework method of binding
synchronization sends values _both_ from parent to child _and_ back
out from child to parent. If the child changes the value of a
variable that has the same name as a binding, this value may be
sent back out to the parent, replacing the parent's original value.
If that's what's going on and it's undesirable, the solution is
usually handling binding value setting and getting yourself,
instead of letting the framework do it for you. See the
synchronizesVariablesWithBindings method.
Forgive me if I'm misunderstanding your question or your
perspective. I hope this helps.
--Jonathan
It seems they are. Originally I had passed the item into Page from
a previous
page and everything displays properly... but when I try to save any changes
nothing is changed.
How do the pros handle this pattern?
-James Cicenia
_______________________________________________
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.
_______________________________________________
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.