Re: Overriding component in a framework ???
Re: Overriding component in a framework ???
- Subject: Re: Overriding component in a framework ???
- From: Peter Vandoros <email@hidden>
- Date: Fri, 02 Sep 2005 15:39:41 +1000
Thanks for responding Chuck :)
I was already aware i could specify components using their full paths. I
have also already tried ordering the classpath in hope that it would use
the desired component to no avail :(.
Unfortnately, most of my pages are referenced from the framework code
and it would be a long and tedious task to duplicate every single
reference in the framework so it will use the new page component.
I have come up with a workaround that overrides pageWithName() in
Application and checks to see if the component exists withing the
application, if it does it will prepend the correct package path,
otherwise it calls super.pageWithName() with the original page name.
I was hoping someone could enlighten me with the "proper" or "better"
way to do it.
Thanks
Peter
Chuck Hill wrote:
The answer is easy. Fixing your framework / application might not be
so easy. When you have components with the same name in different
packages, you need to specify the pack when creating the component.
e.g. instead of pageWithName("TestComponent") use pageWithName
(com.foo.bar.components.TestComponent");
I think that NSBundle determines the search order from the order on
the classpath, but I would not like to depend on that undocumented
implementation.
Chuck
On Sep 1, 2005, at 10:09 PM, Peter Vandoros wrote:
I have recently turned an application into a framework with the hope
of creating another application using the new framework as the base
(extending Application, Session, etc... classes) and "overriding"
some components to provide some customization for a client without
affecting the main application (the new framework).
All seemed to go well until I tried to override one of these
components.
It seems that my application is using the component template from
the application but using the
java class from the framework rather than the applications java class.
Example
Framework contains TestComponent.wo
package com.foo.components;
public class TestComponent extends WOComponent {
public TestComponent(WOContext woContext) {
super(context);
}
public WOComponent testAction() {
System.out.println("Test Action called from framework");
return null;
}
... more functionality here ...
}
Application also contains TestComponent.wo
package com.foo.bar.components;
public class TestComponent extends com.foo.components.TestComponent {
public TestComponent(WOContext woContext) {
super(context);
}
public WOComponent testAction() {
System.out.println("Test Action called from application");
return null;
}
}
After looking into this for some time I belive I have tracked it
down to NSBundle searching the available packages in the wrong order.
When I print the application bundle I get something like this.
<com.webobjects.foundation.NSBundle name:'fooapplication'
bundlePath:'C:\Projects\Fubar' packages:'("com.foo.components",
"com.foo.bar.components")' 256 classes >
So it seems obvious that its looking in the framework
'com.foo.components' package before it looks in the applications
'com.foo.bar.components' package.
Does anyone know how this package order is determined or have any
other suggestions on how this problem can be fixed.
Any help would be greatly appreciated.
Thanks
Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
_______________________________________________
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