Re: Constructors
Re: Constructors
- Subject: Re: Constructors
- From: David Griffith <email@hidden>
- Date: Thu, 06 Nov 2003 02:49:57 +0100
Chuck,
Thanks that helped a bit.
What I was trying to achieve was to have a wrapper page which would provide
a header/footer (which will be used by all pages).
A sub-wrapper that already has a header/footer and would be used by MOST of
the page on the site - those that don't would just use the header/footer
above directly.
Multiple content pages that would automatically have header/footer and menu
by virtue of being wrapped by the above page.
Obviously I'm on the wrong track. I get what you said about not inheriting,
makes sense now that you say it :-)
So, if I want to implement the above scenario with as little replication as
possible, how do I do it? And how can the header/footer page see a value
that my content page has at construction time so that it can set the value
of conditionals (or even have the value directly bound to a conditional) in
itself.
For example, the header/footer will provide the header tags for the page.
What I wanted to do was include a conditional in the header which would
bring in a javascript. The boolean and the javascript filename would both
be in the content page.
I'm pretty confused on the whole component communication issue as you can
see :-) Especially about the bindings.
Regards,
Dave.
> David,
>
> You are confusing Java inheritance and page composition. Inheritance is
> about commonality in function, A is like B. Page Composition is making a
> whole out of parts.
>
>> Page 1 constructor
> Constructing page 3, executing code inherited from Page 1
>
>> Page 2 constructor
> Constructing page 3, executing code inherited from Page 2
>
>> Page 3 constructor (this is much as I expected)
> Constructing page 3
>
>> Page 1 constructor (again)
> Constructing page 2, executing code inherited from Page 1
>
>> Page 2 constructor (again)
> Constructing page 2
>
>> Page 1 constructor (AGAIN).
> Constructing page 2
>
> You now have three objects that know nothing about each other. This is not
> what you want. A menu is not a kind of header/footer. Content is not a
> type of menu nor a type of header footer. Do not make these inherit from
> each other.
>
> 1. Create a new page.
> 2. Drag the Header/Footer onto it.
> 3. Drag the menu and drop it into the header/footer
> 4. Drag the content and drop it into the header/footer below the menu.
>
> The .html for this component should look like this:
> <webobject name=HeaderFooter>
> <webobject name=Menu></WebObject><br/>
> <webobject name=Content></WebObject>
> </WebObject>
>
> This new page holds the common information in variables which is exchanged
> with the HeaderFooter, Menu, and Content via bindings.
>
> That was kind of rushed, but does it make any more sense now?
>
>
> Chuck
>
>
>
> At 12:59 AM 06/11/2003 +0100, David Griffith wrote:
>> Hi Michael,
>>
>> What do you mean exactly?
>>
>> HeaderFooter page contains a WOComponentContent and a header and footer.
>> Page 2 contains a Menu which is itself another component, as well as a
>> WOComponentContent and the whole page is wrapped by HeaderFooter (which is
>> what I want, can't see any other way to do this). Page 3 contains an image
>> for example and the entire contents are wrapped by Page 2. The output is
>> exactly as I want it.
>>
>> I have defined Page 2 to extend Page 1 (subclassed it) and I have defined
>> Page 3 to extend Page 2 (subclassed it).
>>
>> So the way I see it, when I instantiate Page 3, I should and do get a page
>> which has a header and footer, a menu and my image content.
>>
>> When looking at Page 3 in WO Builder it can see all the variables and method
>> of Page 2 and 1 as expected. I can bind and assign to variables which
>> belong to Page 1 from Page 3 and it works fine. But I need to set some
>> values while the page is being constructed (in their 'constructor') so that
>> conditionals can be evaluated and while the construction is happening, all
>> these values are null.
>>
>> I have no idea where to go next.
>>
>> Dave.
>>
>>
>>> Have you tried to embed the WOComponents with in each other instead?
>>>
>>> Michael
>>> www.aspireauctions.com
>>>
>>> On Nov 5, 2003, at 5:46 PM, David Griffith wrote:
>>>
>>>> Ok, now that I have a slightly better idea of how components work,
>>>> here is a
>>>> scenario:
>>>>
>>>> Page 1 Header Footer Page
>>>> Page 2 Menu Page, wrapper with Header Footer
>>>> Page 3 Content Page , wrapper with Menu Page
>>>>
>>>> Page 2 extends Page 1
>>>> Page 3 extends Page 2
>>>>
>>>> Therefore Page 3 can see and use Page 1 and Page 29s methods and
>>>> variables.
>>>>
>>>> However, when I instantiate Page 3, I get the following constructor
>>>> calls:
>>>>
>>>> Page 1 constructor
>>>> Page 2 constructor
>>>> Page 3 constructor (this is much as I expected)
>>>> Page 1 constructor (again)
>>>> Page 2 constructor (again)
>>>> Page 1 constructor (AGAIN).
>>>>
>>>> Does this make sense and if so, can someone please tell me why?
>>>>
>>>> Also, setting variable values that belong to Page 1 from Page 3
>>>> results in
>>>> them being set whilst in the constructor of Page 3 but in all other
>>>> locations above they are null.
>>>>
>>>> Once control returns to Page 3, the values exist. But they are values
>>>> that
>>>> the construction process depends on.
>>>>
>>>> Regards,
>>>> Dave.
>>>> _______________________________________________
>>>> 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.
>>
>
> --
>
> Chuck Hill email@hidden
> Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
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.