File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

messagesPresent problem for displaying actionMessage

 
Donald Fung
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all

I feel dizzy to solve this problem in few days. I had searched the forum and tried many solutions but not help.
I hope somebody can help me. Thanks.

The problem is I cannot display the messages in the jsp, it seems that <logic:messagesPresent> always returns false.
I have tried to use the common log to retrieve the saved messages from the request and sure that the message is present.

The web is using jdk1.4.11 + jrun4 + struts 1.2.9 .



Here is the action class:



web.xml


The jsp:


Log message(by common log):

1382 / 1414 06/07 18:43:40 info [axis] Tiles definition factory found for request processor ''.
1383 / 1414 06/07 18:43:44 info [axis] {org.apache.struts.action.GLOBAL_MESSAGE=[The customer does not define location yet. Please input them before.[]]}
1384 / 1414 06/07 18:43:45 info [axis] {org.apache.struts.action.GLOBAL_MESSAGE=[The customer does not define location yet. Please input them before.[]]}
1385 / 1414 06/07 18:43:46 info [axis] {org.apache.struts.action.GLOBAL_MESSAGE=[The customer does not define location yet. Please input them before.[]]}
1386 / 1414 06/07 18:43:48 info [axis] {org.apache.struts.action.GLOBAL_MESSAGE=[The customer does not define location yet. Please input them before.[]]}
[ June 07, 2006: Message edited by: Donald Fung ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is the way you're constructing messages. The String parameter that the ActionMessage constructor accepts is not for the message itself, but for a message key which is to be found in the ApplicationResources.properties file.

In your example, you should make the following entry in ApplicationResources.properties:

error.undefined.location=The customer does not define location yet. Please input them before.

Then in your action class, code this;

messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.undefined.location"));

Seethis link for more information on how to set up and configure your message resources.
 
Donald Fung
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works now.

Thanks, Merrill.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic