Return-Path: Mailing-List: contact tapestry-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tapestry-user@jakarta.apache.org Received: (qmail 13101 invoked from network); 18 Aug 2003 12:24:14 -0000 Received: from smtp.brightspark.com (66.46.21.156) by daedalus.apache.org with SMTP; 18 Aug 2003 12:24:14 -0000 Received: from localhost (joshua [127.0.0.1]) by smtp.brightspark.com (Postfix) with ESMTP id 9FEB87005C for ; Mon, 18 Aug 2003 08:30:37 -0400 (EDT) Received: from smtp.brightspark.com ([127.0.0.1]) by localhost (joshua [127.0.0.1]) (amavisd-new, port 10029) with ESMTP id 21382-07 for ; Mon, 18 Aug 2003 08:30:37 -0400 (EDT) Received: from scooby.corp.bspark.com (gateway.brightspark.com [66.46.41.93]) by smtp.brightspark.com (Postfix) with ESMTP id 1C59D70040 for ; Mon, 18 Aug 2003 08:30:37 -0400 (EDT) Received: from exis.com ([10.5.200.133]) by scooby.corp.bspark.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 18 Aug 2003 08:24:14 -0400 Message-ID: <3F40C56E.7060207@exis.com> Date: Mon, 18 Aug 2003 08:24:14 -0400 From: Colin Sampaleanu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: tapestry-user@jakarta.apache.org Subject: Any way to get ServletContext at time 'property-specifications' are processed? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Aug 2003 12:24:14.0632 (UTC) FILETIME=[A3001A80:01C36583] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N (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 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: @com.interface21.web.context.support.WebApplicationContextUtils@getWebApplicationContext(requestCycle.requestContext.applicationServlet.servletContext) 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) { super.setupForRequest(context); // insert ApplicationContext in global, if not there Map global = (Map) getGlobal(); ApplicationContext ac = (ApplicationContext) global.get(APPLICATION_CONTEXT_KEY); if (ac == null) { ac = WebApplicationContextUtils.getWebApplicationContext(context.getServlet().getServletContext()); global.put(APPLICATION_CONTEXT_KEY, ac); } } and then in the property specification I use an OGNL expression like: global.appContext.getBean("myMapper") 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... Regards, Colin --------------------------------------------------------------------- To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org