Re: Overriding component in a framework ???
Re: Overriding component in a framework ???
- Subject: Re: Overriding component in a framework ???
- From: Chuck Hill <email@hidden>
- Date: Thu, 1 Sep 2005 22:18:35 -0700
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
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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