You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Lewis <bu...@gmail.com> on 2008/01/29 18:33:16 UTC

T5: inject Request into contributeApplicationDefaults

Hello,

My app needs to know about a directory that may or may not exist in the 
context path (if it doesn't exist, it will create it). I thought I could 
use symbols to expand such paths, but I cannot. Here's what I was trying 
in my contribution:

    public static void 
contributeApplicationDefaults(MappedConfiguration<String, String> 
configuration) {
       
        /* Context-provided paths and resources. */
        configuration.add("images.root", "context:img");

       //......
      
       configuration.add("blog.uploads.images",  
"${images.root}/img/blog/uploads");
    }

As currently implemented, if I want prefixes like 'context:' to be 
resolved I have to use something like @Path, otherwise I get the 
unresolved string 'context:'. However @Path assumes the argument is an 
asset, and that asset must exist or an exception will be thrown. It'd be 
nice prefixes like 'context:' could be resolved outside of @Path, but as 
an alternative I tried to inject Request into my contribution. I tried 
these variations:

public static void 
contributeApplicationDefaults(MappedConfiguration<String, String> 
configuration, Request request) {}

public static void 
contributeApplicationDefaults(MappedConfiguration<String, String> 
configuration, @Inject Request request) {}

public static void 
contributeApplicationDefaults(MappedConfiguration<String, String> 
configuration, @InjectService("Request") Request request) {}

Each time I get the same exception, that request 
(org.apache.tapestry.services.Request) is null.

Can anyone offer some input on how I can get any of these methods to work?

thanks,
chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org