Dashboard > WebWork 1 > WebWork CookBook > SessionAware Actions
  WebWork 1 Log In View a printable version of the current page.  
  SessionAware Actions
Added by Joseph Ottinger, last edited by Hani Suleiman on Apr 25, 2004  (view change)
Labels: 
(None)

SessionAware actions are actions that receive information about their state from the execution environment. This has been deprecated, because Actions can get state information from ActionContext and ServletActionContext (if, of course, they're in a servlet).

webwork.action.SessionAware is an interface; Actions that wish to be session-aware in the deprecated sense receive the session information passively (by having a method called that provides a map to the session data) as opposed to the preferred method of having the Action call ActionContext.getContext() (as well as the corresponding method in ServletActionContext).

Thus, you might use the SessionAware interface like this:

public class MyAction extends ActionSupport implements SessionAware {
   protected Map session;
   public void setSession(Map m) {
      session=m;
   }
   // extra code follows...
}

The session data will now be available via the session variable. Calling session.clear() will magically invalidate the servlet session (if, of course, this is a servlet session).

The interface SessionAware has been marked deprecated for WebWork 1.3.0 ...

What about using this alternative: ?

Map session = ActionContext.getSession();
session.put("key", value);

Posted by Anonymous at Apr 29, 2003 06:39 | Permalink

Why is this deprecated?

Doesn't calling ActionContext.getContext() break Inversion of Control?

It's also much easier to endo-test with MOs the SessionAware case.

Posted by Anonymous at Nov 20, 2003 23:12 | Permalink

I'm using WebWork 2.1 and don't see the @deprecated tag on SessionAware interface...

Posted by Anonymous at Jul 07, 2004 13:37 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators