• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Messages displayed only if I use saveErrors()

 
Nick White Ro
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to add messeage="true" to your html:messages:

<html:messages id="error" property="errors" messeage="true">
 
Nick White Ro
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic