| Author |
messagesPresent problem for displaying actionMessage
|
Donald Fung
Greenhorn
Joined: Oct 27, 2004
Posts: 18
|
|
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
Joined: Feb 15, 2005
Posts: 4864
|
|
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.
|
Merrill
Consultant, Sima Solutions
|
 |
Donald Fung
Greenhorn
Joined: Oct 27, 2004
Posts: 18
|
|
It works now. Thanks, Merrill.
|
 |
 |
|
|
subject: messagesPresent problem for displaying actionMessage
|
|
|