tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Sampaleanu <colin...@exis.com>
Subject Any way to get ServletContext at time 'property-specifications' are processed?
Date Mon, 18 Aug 2003 12:24:14 GMT
(sorry, I accidentally sent this to tapestry-dev instead of 
tapestry-user. question still stands)

Can anybody think of a way to the get ServletContext at the time that a 
page's <property-specification> elements are processed?

In the property-specification, I need to have an OGNL expression which 
calls a static member of a class, and feeds it the ServletContext, to 
get back a bean reference in return. Now I tried this for the expression:

but unfortunately it doesn't work, since at the time 
property-specifications are processed, requestCycle's requestContext 
field is still null.

What I have done instead is overriden the Engine class, and stuck a 
reference to what I need in a global object, as follows:

 public static final String APPLICATION_CONTEXT_KEY = "appContext";
 protected void setupForRequest(RequestContext context) {
   // insert ApplicationContext in global, if not there
   Map global = (Map) getGlobal();
   ApplicationContext ac = (ApplicationContext) 
   if (ac == null) {
     ac = 
     global.put(APPLICATION_CONTEXT_KEY, ac);

and then in the property specification I use an OGNL expression like:


This works, but what I don't like about this approach is that I have to 
have a custom Engine class, and have to use the Global. I guess it's not 
that big a deal, but I would still like to know if anybody can think of 
a way to get the ServletContext through OGNL at that time...



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

View raw message