Re: Showing messages after a redirect

2013-03-28 Thread pdegregorio
Adam Hardy (struts) wrote
> Dimitris Mouchritsas on 01/07/08 16:50, wrote:
> 
> actually you can put the messages collection into the session if you're ok
> to 
> manage it yourself.
> 
> session.setAttribute(Globals.MESSAGE_KEY, messages);
> 
> and then in the next action redirected to:
> 
> ActionMessages messages = new ActionMessages((ActionMessages)
> request.getAttribute(Globals.MESSAGE_KEY));
> messages.add((ActionMessages)
> session.getAttribute(Globals.MESSAGE_KEY));

Thank you. This worked for me when I added the following line to the 2nd
block of code (the next action redirected to)

saveMessages(request, messages);




--
View this message in context: 
http://struts.1045723.n5.nabble.com/Showing-messages-after-a-redirect-tp3481980p5712345.html
Sent from the Struts - User mailing list archive at Nabble.com.

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



Re: Showing messages after a redirect

2008-07-02 Thread Dimitris Mouchritsas

Adam Hardy wrote:

Dimitris Mouchritsas on 01/07/08 16:50, wrote:


Yes, for Struts 1.3.8, sorry I forgot to mention. Actually what I did 
(but
it's more or less specific for the action) is to just forward, not 
redirect.
But I've got another question now? Is there a way I can pass a 
parameter in

the request? I need to pass an id for an Account when I go back to the
Prepare action. But since I'm not manipulating the url?


And you can pass a parameter in the request if you built a new Forward 
based on the one you want and construct the URL manually. I dug this 
out of an old app:


forward = mapping.findForward(origForward);
forwardName = forward.getName();
redirect = forward.getRedirect();
//change URL if different URL given
forwardUrl = "/somewhere/else";
forwardUrl += "?" + customQueryString;
forward = new ActionForward(forwardName, forwardUrl,
redirect);



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Aaah, great; that seems to solve both of my problems :)
Thank you
Dimitris

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Adam Hardy

Dimitris Mouchritsas on 01/07/08 16:50, wrote:



Yes, for Struts 1.3.8, sorry I forgot to mention. Actually what I did (but
it's more or less specific for the action) is to just forward, not redirect.
But I've got another question now? Is there a way I can pass a parameter in
the request? I need to pass an id for an Account when I go back to the
Prepare action. But since I'm not manipulating the url?


And you can pass a parameter in the request if you built a new Forward based on 
the one you want and construct the URL manually. I dug this out of an old app:


forward = mapping.findForward(origForward);
forwardName = forward.getName();
redirect = forward.getRedirect();
//change URL if different URL given
forwardUrl = "/somewhere/else";
forwardUrl += "?" + customQueryString;
forward = new ActionForward(forwardName, forwardUrl,
redirect);



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Adam Hardy

Dimitris Mouchritsas on 01/07/08 16:50, wrote:

Ian Roughley wrote: Yes, for Struts 1.3.8, sorry I forgot to mention.
Actually what I did (but it's more or less specific for the action) is to
just forward, not redirect. But I've got another question now? Is there a way
I can pass a parameter in the request? I need to pass an id for an Account 
when I go back to the Prepare action. But since I'm not manipulating the 
url?



actually you can put the messages collection into the session if you're ok to 
manage it yourself.


session.setAttribute(Globals.MESSAGE_KEY, messages);

and then in the next action redirected to:

ActionMessages messages = new ActionMessages((ActionMessages)
   request.getAttribute(Globals.MESSAGE_KEY));
messages.add((ActionMessages)
   session.getAttribute(Globals.MESSAGE_KEY));


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Dimitris Mouchritsas

Ian Roughley wrote:

my mistake, only saw the last message.

Antonio Petrelli wrote:

2008/7/1 Ian Roughley <[EMAIL PROTECTED]>:
 

Have you looked at the message store interceptor?



For Struts 1?

Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Yes, for Struts 1.3.8, sorry I forgot to mention. Actually what I did 
(but it's more or less
specific for the action) is to just forward, not redirect. But I've got 
another question now?
Is there a way I can pass a parameter in the request? I need to pass an 
id for an Account
when I go back to the Prepare action. But since I'm not manipulating the 
url?


Dimitris

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Ian Roughley

my mistake, only saw the last message.

Antonio Petrelli wrote:

2008/7/1 Ian Roughley <[EMAIL PROTECTED]>:
  

Have you looked at the message store interceptor?



For Struts 1?

Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Antonio Petrelli
2008/7/1 Ian Roughley <[EMAIL PROTECTED]>:
> Have you looked at the message store interceptor?

For Struts 1?

Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Ian Roughley

Have you looked at the message store interceptor?

/ian

Antonio Petrelli wrote:

2008/7/1 Dimitris Mouchritsas <[EMAIL PROTECTED]>:
  

ActionMessages msg = new ActionMessages();
msg.add(Constants.MESSAGE_CONFIRM, new
ActionMessage("prompt.changes.saved"));
saveMessages(request, msg);

But when I'm redirected back in the jsp there's no message showing (there's
a specific tile for
messages).



Heh, that's a good one: I think it is not possible to use
ActionMessages, since they remain active only in the current request.
When you redirect you are in fact creating a new request, and the
messages will disappear.
Other frameworks, like Struts 2, have a "flash" scope, that is
available just the time of one single redirect. It works by putting
temporarily objects in session and then putting them back in request
after the redirect.
You could put these messages in session and use a filter (to .jsp
files) to put them back to request.
Or you can take a look at the "click" scope of Scopes:
http://scopes.sourceforge.net/documentation/more-scopes/click-scope.html

Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Showing messages after a redirect

2008-07-01 Thread Antonio Petrelli
2008/7/1 Dimitris Mouchritsas <[EMAIL PROTECTED]>:
> ActionMessages msg = new ActionMessages();
> msg.add(Constants.MESSAGE_CONFIRM, new
> ActionMessage("prompt.changes.saved"));
> saveMessages(request, msg);
>
> But when I'm redirected back in the jsp there's no message showing (there's
> a specific tile for
> messages).

Heh, that's a good one: I think it is not possible to use
ActionMessages, since they remain active only in the current request.
When you redirect you are in fact creating a new request, and the
messages will disappear.
Other frameworks, like Struts 2, have a "flash" scope, that is
available just the time of one single redirect. It works by putting
temporarily objects in session and then putting them back in request
after the redirect.
You could put these messages in session and use a filter (to .jsp
files) to put them back to request.
Or you can take a look at the "click" scope of Scopes:
http://scopes.sourceforge.net/documentation/more-scopes/click-scope.html

Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]