On 9/23/05, Joe Germuska <[EMAIL PROTECTED]> wrote:
>
> I was experimenting with a local subclass of ActionContext which
> added itself to a ThreadLocal in the constructor, so that I could in
> theory get access to the ActionContext from classes which don't get
> it passed in. (I wanted to use it in a TilesController, for example,
> or maybe in a JSTL function.)


JSF does the same kind of thing ... you can call the static method
FacesContext.getCurrentInstance() to get the FacesContext instance for the
current request. Internally, its stored in a ThreadLocal maintained by the
JSF implementation.

Anyway, my view-level code isn't seeing the value, so I guess that
> means that requestDispatcher.forward() spawns a new thread. This
> makes sense, but I hadn't thought of it that way.


Forwarding had better *not* create a new thread ... that would violate the
servlet spec. Something else must be going on.

Craig

The problem here is that making the ActionContext available to the
> View is problematic, since ActionContext.release() is going to be
> called asynchronously from the view processing -- so even putting the
> context in the request is problematic.
>
> That said, I've maintained a design for my subclasses of
> ActionContext so that you can always safely make one as a wrapper to
> the ServletContext, Request, and Response -- the ActionContext itself
> has no state. This works pretty well, and I was able to do it in the
> TilesController and also in a DWR remote object (and DWR doesn't even
> use Struts for request processing). Perhaps we should just document
> this fact and advise people accordingly -- "if you extend
> ActionContextBase, be careful not to add any instance variables, or
> you may lose this functionality.)"
>
> Just thought I'd share...
>
> Joe
>
> --
> Joe Germuska
> [EMAIL PROTECTED]
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction" -The Ex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to