struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Al Sutton">
Subject RE: [S2] ActionMessages and redirects
Date Mon, 04 Jun 2007 05:59:17 GMT
Hi Gunnar,

I've been through the same thing, so I can help you out :).

If your actions extend com.opensymphony.xwork2.ActionSupport you can then
call the method;




Please note, "string" is the literal message, not a key into a properties

If you want to use a properties file for multi-language systems you need to
do the following;




And create a file called in your action package (or at
some point above in the package hierarchy) which has the translations.

You will need to use the message store interceptor where you are using a
redirect (i.e. you will need it in the redirect to the get), you should note
though, at the moment there appears to be a bug in that if you use
addActionError, the message store interceptor, and you have the validation
interceptor enabled you will get redirected to the input result of the
action after the redirect :(.

Hope this helps,


-----Original Message-----
From: Gunnar Hillert [] 
Sent: 04 June 2007 05:52
Subject: [S2] ActionMessages and redirects


Still learning but I am really going to like Struts 2. An area where I find
it a bit lacking though (Compared to Struts 1) is the support for action
messages to survive redirects. 

I really like to follow the 'Post/Redirect/Get pattern' for most of my
(See also

Therefore in most of my actions I have the requirement that my success
messages survive the next redirect.

In Struts 1 I can do:

                       new ActionMessage("user.added"));
saveMessages(request.getSession(), messages);

But there is nothing like this in Struts 2.

I did not find too much information about this requirement in Struts 2. 
There are 2 open issues in Jira that touch the issue:

On of the issues mentions the MessageStore interceptor but that looks a bit
like overkill to me. (See also

Thus, for right now I am using Appfuse's solution of using a custom filter. 

This works great but somehow feels like a 'hack' (Had to do the same for my
Spring MVC projects.)

* * *

In a perfect world I would like to see a feature similar to Ruby on Rails'
Flash which allows you to not only store messages but any object in a Flash,
and hence those objects survive the next redirect.

See also

But for the time being I would be already quite happy if there was a simple
and standardized way to have my actionMessages survive redirects.

What is the status on that? Is this something that will be added to one of
the next Struts 2 releases?

Thanks a lot! 


Gunnar Hillert 

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message