Thanks Philip, I'll give this a try. How does this affect the default
behaviour of the framework setting the context when an action is
instantiated?

Chris

On Sat, May 23, 2009 at 6:59 PM, Philip Constantinou
<[email protected]> wrote:
> We do similar stuff by adding these helper methods to our ActionBeanContext
> subclass. Your tag should have enough information from the page context to
> call getOrMakeContext(...).
>
>
>
>   /**
>    * If an  My context has already been set, this will grab it, otherwise
>    * this will make a new context.
>    */
>   public static MyActionBeanContext getOrMakeContext(
>       HttpServletRequest httpRequest, HttpServletResponse httpResponse,
>       ServletContext servletContext) {
>     MyActionBeanContext context = MyActionBeanContext
>         .getContext(httpRequest);
>     if (context == null) {
>       context = new MyActionBeanContext();
>       context.setRequest(httpRequest);
>       context.setResponse(httpResponse);
>       context.setServletContext(servletContext);
>     }
>     return context;
>   }
>
>
>
>   /**
>    * Retrieves the global context associated with the provideed request, or
> null
>    * if none is set.
>    */
>   public static MyActionBeanContext getContext(ServletRequest request) {
>     return (MyActionBeanContext) request
>         .getAttribute(My_CONTEXT_REQUEST_ATTRIBUTE);
>   }
>
>
>
>   @Override
>   public void setRequest(HttpServletRequest request) {
>     super.setRequest(request);
>     if (getContext(request) == null) {
>       request.setAttribute(My_CONTEXT_REQUEST_ATTRIBUTE, this);
>     }
>   }
>
>
>
>
> On May 23, 2009, at 3:45 PM, Mike McNally wrote:
>
> On Sat, 23 May 2009 14:44:27 -0700
> Chris Cheshire <[email protected]> wrote:
>
> I have quite a few convenience methods in my action bean context
>
> subclass (eg. that wrap getting init parameters for the web
>
> application) that I want to access from a tag handler class. I can get
>
> the servlet context and then get the params from that, but the methods
>
> in the action bean context are more...convenient. Is there any way to
>
> get access to this instance from a tag handler class?
>
> I think that a common way to do this is to either subclass the context
> class such that the instances put themselves in a ThreadLocal and
> provide a public static access method, or to have an interceptor
> do that for the stock class.
>
> --
> --
> Mike McNally <[email protected]>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals.
> Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals.
> Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to