File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes SessionAware does not inject session Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "SessionAware does not inject session Object " Watch "SessionAware does not inject session Object " New topic
Author

SessionAware does not inject session Object

Diego Magalhães
Greenhorn

Joined: Jun 13, 2008
Posts: 4
Hello guys,

Once more here I come with a question of s2, i'm a beginner at it and got some trouble finding examples.

I'm build a menu service wich depends upon a login, wich is give when the user enter at start page. Once the login has been made, I store the user object into the session by doing the follow:




and then the doLogin method


Now comes the problem, I have a MenuBean injected on the MenuAction by the following xml piece on ApplicationContext.xml





And the menuAction is declared as follow:


By doing so I need to implement the session set with a private member


The failing part of all its the method bellow, the session object is null at debugging:

Does anyone know why? or how to implement it? Looking at the code above, i need 'Perfil' from the user wich is logged on, if the session contains the key to the user object i get it and then use the perfil to populate the Menu through the setter and return SUCESS, otherwise it'll return INPUT wich will lead to the login screen.


Thanks in advance.

"Sanity calms, but madness is more interesting."<br />- John Russell
Diego Magalhães
Greenhorn

Joined: Jun 13, 2008
Posts: 4
After some ours I managed to discover the error. wich lies not in the program but in the struts.xml, I've written a custom stack for the application:





And somewhat forgot to include session-related items, with the defaultLoginStack changed to




I'm now able to use session injected correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SessionAware does not inject session Object
 
Similar Threads
[Struts2] losing display only(prepopulated) values of the form if the validaiton fails
The value for the useBean class attribute is invalid
Problem with this Action class
authenticating User!
Use Rultime Expressions in Struts 2 tags