Thank you Dale,

Let me see if I understand this correctly.  Since the action object has
not been created yet, and this is in a different thread... I can not get
the correct context...  Although the session objects _is_ someplace...
It will also not work in the constructor even if the class is
SessionAware because the object must exist before setSession(Map m)
could be called... 

So...
I should really be treating execute() as my constructor for now... until
I better understand when the session variable becomes available.
Struts2 needs to see who I am before it knows my session right?  So it
isn't going to provide it to me until it has done a certain amount of
set up?

Ken.


On Tue, 2010-05-18 at 12:49 -0400, Dale Newfield wrote: ActionContext my
current method is local to the thread so I can't use that 

> On 5/18/10 12:35 PM, Ken wrote:
> > What I don't understand is I have an object who's constructor needs
> > session data...
> > So it calls:
> > Map session = ActionContext.getContext().getSession();
> >
> > But session is always null...
> 
> http://struts.apache.org/2.1.8.1/struts2-core/apidocs/com/opensymphony/xwork2/ActionContext.html#getContext()
> 
> Explains that this static method works by looking up the value in a 
> ThreadLocal: "Returns the ActionContext specific to the current thread."
> 
> So if that constructor is happening within the same thread in which the 
> request was originally being processed, and after xwork finishes setting 
> up that context, it should work:
> 
> "The ActionContext is thread local which means that values stored in the 
> ActionContext are unique per thread. See the ThreadLocal class for more 
> information."
> 
> But random code in a random thread occurring at a random time cannot 
> rely on ActionContext.getContext().
> 
> I'd check out the *Aware interfaces if I were you.
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 












Reply via email to