Ohno -

you almost had it, except the PageTemplateLocatorImpl takes some constructor arguments to set it up.

The following snippet should work in your AppModule.

Note how the method name "buildMyLocator" automatically gives that service the name "MyLocator".


-----------------------

public PageTemplateLocator buildMyLocator(@ContextProvider AssetFactory contextAssetFactory,

ComponentClassResolver componentClassResolver) { return new PageTemplateLocatorModified(contextAssetFactory.getRootResource(), componentClassResolver);
    }


    public static void contributeAliasOverrides(
            @InjectService("MyLocator")PageTemplateLocator locator,
            Configuration<AliasContribution> configuration) {
configuration.add(AliasContribution.create(PageTemplateLocator.class, locator));
    }

-----------------------

I've testing this with 5.0.8-SNAPSHOT and I am able to .html "page" files from the context root. I don't think this will work with 5.0.6, but maybe 5.0.7


Hope it works for you,
mike


On Dec 30, 2007, at 6:35 AM, Onno Scheffers wrote:


if your designers are only designing "pages" and not "components" that will end up in your app's context root (not packaged away in a jar) then you could probably get away with just contributing a PageTemplateLocator in your AppModule.

Hi Michael,

Thanks for your reply. The designers do indeed only design pages, so it seems like your solution is the way to go about it. I haven't been able to get this to work though. Maybe you can point out what I'm doing wrong here?

In my AppModule I have this code:
public static void bind(ServiceBinder binder) {
binder.bind(PageTemplateLocator.class, HTMLTemplateLocator.class).withId("htmlLocator");
}
public static void contributeAliasOverrides(
    @InjectService("htmlLocator") PageTemplateLocator locator,
    Configuration<AliasContribution> configuration) {
configuration .add(AliasContribution.create(PageTemplateLocator.class, locator));
}

My HTMLTemplateLocator is currently just an exact copy from the Tapestry PageTemplateLocatorImpl.

This gives me the following error when I try to access the webapp:

Exception constructing service 'htmlLocator':
Error invoking constructor [MYPACKAGE].HTMLTemplateLocator(Resource, ComponentClassResolver) (at HTMLTemplateLocator.java:31) (for service 'htmlLocator'): No service implements the interface org.apache.tapestry.ioc.Resource.


It seems there's a problem setting up the contextRoot Resource required for calling the constructor of my 'custom' TemplateLocator, but it works for the default PageTemplateLocatorImpl?


Regards,

Onno


---------------------------------------------------------------------
To unsubscribe, e-mail: users-u


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to