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 addActionError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "addActionError" Watch "addActionError" New topic
Author

addActionError

chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Hi gurus,

I have a basic login that calls addActionError from within the Action, and it works perfectly with <s:actionerror />

My problem is that I want to do a similar call from within an Interceptor. Can it be done? If so, how?

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You can get the action in an interceptor, right? (Bearing in mind that if your interceptor stack includes "workflow" you need to make sure your interceptor order matches your desired behavior.)
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Maybe I'm misinterpreting, but yes, the action is encompassed in the interceptor. When the interceptor succeeds I can get to the action, but when it fails it never gets to it so I'm looking for a callback to the form where I can add a coding statement like "addActionError".

Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I think *I'm* probably the one mis-interpreting: what, specifically, are you trying to do? You have the action, so you can call addActionError on it.
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Basically I have an interceptor that checks the user's status. If the user has timed out, they'll be kicked back to the login page no matter where they are in the app. What I'd like to have is some form of user notification to let them know why they need to log back in.

Thinking about it more now, I'm wondering if maybe I should just kick the user to a different login page which has this user message included?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I wouldn't have a completely separate page for that, unless there's a compelling reason to have one. But since you're doing a redirect, unless you're using the message store interceptor, it would be lost anyway, right? So I'd keep it in session and just check if there's a message there or something.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: addActionError
 
Similar Threads
struts 2 + how to redirect Page after Login validation
How to handle java.lang.NullPointerException in Struts2?..
Bean values are null
problem in displaying actionerrors