wood burning stoves 2.0*
The moose likes Struts and the fly likes Messages displayed only if I use saveErrors() 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 "Messages displayed only if I use saveErrors()" Watch "Messages displayed only if I use saveErrors()" New topic
Author

Messages displayed only if I use saveErrors()

Nick White Ro
Greenhorn

Joined: Jan 27, 2010
Posts: 15
I have different types of messages to display to the user - errors, confirmations etc.

This is what I use in my action:


This is what I use for displaying the messages:


The problem is that no messages are displayed. If I change saveMessages() to saveErrors(), it works, but I want to use saveMessages() as I have messages to display other than errors.

I am using Struts 1.3.10.
Katrin Perry
Ranch Hand

Joined: Mar 07, 2007
Posts: 61
You would need to add messeage="true" to your html:messages:

<html:messages id="error" property="errors" messeage="true">


Katrin
SCJP 5.0, SCWCD, SCBCD, Oracle Certified Master Enterprise Architect
Nick White Ro
Greenhorn

Joined: Jan 27, 2010
Posts: 15
Thank you! It works.

I should have payed more atention to the tag documentation, the answer was there.
So, by default, it reads the messages from the request attribute named Globals.ERROR_KEY, and setting the "message" to "true" makes the tag read from Globals.MESSAGE_KEY.

Unfortunately, this brings another problem:
- saveMessages() saves to Globals.MESSAGE_KEY
- saveErrors() saves to Globals.ERROR_KEY
- the messages returned by an ActionForm.validate() will be saved to Globals.ERROR_KEY

So I have to do this to display all messages:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Messages displayed only if I use saveErrors()
 
Similar Threads
Struts newbie question - bean:message
Handling Messages (v1.2.9)
Using ActionMessages to display Errors using errors.headers and errors.footers
Changing ActionErrors to ActionMessages in struts application
html:messages