my dog learned polymorphism
The moose likes Struts and the fly likes arguments for bean:message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "arguments for bean:message" Watch "arguments for bean:message" New topic

arguments for bean:message

Ilja Smoli
Ranch Hand

Joined: Dec 02, 2001
Posts: 64
I want to create kind of centralized jsp page for displayng messages/errors from resource file. Jsp has a folowing line of code:

Now the action class which is executing puts in a request the key for this message like this:
Resource file has a message under the key msg01-01. That is working fine.
Now the question is how to pass an arguments from action to this page? I mean those arguments which in other way would be handled by arg0, arg1 etc parameters in bean:message tag?
Any ideas? Or maybe example of better implementation of such page?
Thx in advance...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I fail to see the advantage in doing it this way over simply populating the ActionMessages object in the Action class and using the <html:messages> tag to display them.

Since the ActionMessages object is stored in the request, you can still use a central JSP to display them, and you will have no problem passing parameters to the message.

For more information on this, see the heading "displaying messages" in this link.
[ June 20, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Ilja Smoli
Ranch Hand

Joined: Dec 02, 2001
Posts: 64
Thanks for reply.
Well I think you are right. I was thinking on this too, but for some reason avoided that way, maybe because creating ActionMessages objects requires more code in Action. Now I think I will stick to it Thanks!
I agree. Here's the link:
subject: arguments for bean:message
It's not a secret anymore!