You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Chris Searle <ch...@empolis.no> on 2004/11/19 11:27:44 UTC

MessageTool - with messages in session

Struts/Tiles/VelocityView

MessageTool works OK with

  saveMessages(request,msgs)

but not with

  saveMessages(request.getSession(),msgs)

which means passing messages where the action has a redirect="true"
doesn't work very well.

I think that StrutsUtils assumes that the messages are in the request
only - is this correct? If so - is there a recommended solution?

I can of course create another tool $sessionMessages - but that seems
a little inelegant :-)

Regards

-- 
Chris Searle
chris@empolis.no


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


Re: MessageTool - with messages in session

Posted by Chris Searle <ch...@empolis.no>.
>>>>> "SK" == Shinobu Kawai <sh...@gmail.com> writes:

    >> I think that StrutsUtils assumes that the messages are in the
    >> request only - is this correct? If so - is there a recommended
    >> solution?

    SK> You can make a patch and post it to bugzilla.
    SK> http://issues.apache.org/bugzilla/enter_bug.cgi?product=Velocity

I'll take a look.

To behave like struts it would need to retrieve from both request and
session (will need to find out what struts does with messages present
in both places).

There may be an issue with scoping of the tool though - especially
when the tiles tool is also used.

I know that here (with a custom tool descended from
ActionMessagesTool) which override init to add messages from the
session to the instance variable - the messages are only present in
the first tile (maybe only the layout - not finished debugging this
yet)!

This is I guess the code that automatically removes the messages from
the session so that they don't get displayed more than once. I'm not
sure how request vs. session scope of the tool affects this either
yet.

If I get it working I'll send a patch :-)

-- 
Chris Searle


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


Re: MessageTool - with messages in session

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Chris,

>  saveMessages(request.getSession(),msgs)

Looks like this is from Struts 1.2.
  http://struts.apache.org/api/org/apache/struts/action/Action.html#saveMessages(javax.servlet.http.HttpSession,
org.apache.struts.action.ActionMessages)

> which means passing messages where the action has a redirect="true"
> doesn't work very well.
> 
> I think that StrutsUtils assumes that the messages are in the request
> only - is this correct? If so - is there a recommended solution?

You can make a patch and post it to bugzilla.
  http://issues.apache.org/bugzilla/enter_bug.cgi?product=Velocity

> I can of course create another tool $sessionMessages - but that seems
> a little inelegant :-)
:-)

Best regards
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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