You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by simpi <si...@yahoo.com> on 2008/03/28 02:39:56 UTC

How to get access to session scoped bean in Struts?

I need to access session scope bean in my java action class which will insert
data from all session beans to the Database.

I know I can access I all session beans in JSP using:
<jsp:useBean id="aa" scope="session" class="package.A" />

How to access this bean in Java Action Class?

Please Help me !!! :(
-----
In JSF people do it :
FacesContext facesContext = FacesContext.getCurrentInstance();
ApplicationFactory appFactory =
(ApplicationFactory)FactoryFinder.findFactory(FactoryFinder.APPLICATION_FACTORY);
Application app = appFactory.getApplication();
AppState appState =
(AppState)app.getValueBinding("appState").getValue(facesContext);
:working:
-- 
View this message in context: http://www.nabble.com/How-to-get-access-to-session-scoped-bean-in-Struts--tp16343878p16343878.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to get access to session scoped bean in Struts?

Posted by diogo pontual <di...@gmail.com>.
Try to implement the org.apache.struts2.interceptor.SessionAware
interface. It defines a method called setSession(java.util.Map
session).

[]',s

Diogo

On Thu, Mar 27, 2008 at 10:39 PM, simpi <si...@yahoo.com> wrote:
>
>  I need to access session scope bean in my java action class which will insert
>  data from all session beans to the Database.
>
>  I know I can access I all session beans in JSP using:
>  <jsp:useBean id="aa" scope="session" class="package.A" />
>
>  How to access this bean in Java Action Class?
>
>  Please Help me !!! :(
>  -----
>  In JSF people do it :
>  FacesContext facesContext = FacesContext.getCurrentInstance();
>  ApplicationFactory appFactory =
>  (ApplicationFactory)FactoryFinder.findFactory(FactoryFinder.APPLICATION_FACTORY);
>  Application app = appFactory.getApplication();
>  AppState appState =
>  (AppState)app.getValueBinding("appState").getValue(facesContext);
>  :working:
>  --
>  View this message in context: http://www.nabble.com/How-to-get-access-to-session-scoped-bean-in-Struts--tp16343878p16343878.html
>  Sent from the Struts - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Diogo Dauster Pontual
diogopontual@gmail.com
61.81588922

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org