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

Struts error message

 
M Murthy
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using <html:messages> to display error messages ActionMessages populated in the action class.

<html:messages property="selectError" id="selectError">
<bean:message key="<%=selectError%>"/>
</html:messages>

The problem is that every time an error message is displayed, it looks like this

???en_US.my error message from ApplicationResources file.???

How do i get rid of the ???en_us. and ??? at the end of the error messages?

Thanks in advance
 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this link for help on the same problem.
 
M Murthy
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the quick reply. I went through the link, but the problem i am facing is slightly different. I am able to retrieve the messages from the ApplicationReosurces.properties file. As in any key that i use gets translated to the actual message in the properties file. But i have this unwanted ???en_US. attached to the beginning of the message and ??? attached to the end of the message.

Please let me know if anybody has a solution....
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That unwanted stuff usually gets added to the beginning and end of a key that could not be found.
 
Sujatha Kumar
Ranch Hand
Posts: 134
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Murthy,

I think you have not put error code key and message in the ApplicateResources.properties.

Struts will look out for the error code key in the ApplicateResources.properties, so when it is not found
it may show up this error.

Regards
 
M Murthy
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sujatha


I think you have not put error code key and message in the ApplicateResources.properties.


I have defined the key and messages in the props file. Please note that the key in the JSP page is retrieving the appropriate error message and displaying it. So its not a problem of locating the props file or translating the key to the actual message. All that is working fine. The only problem is the ???en_US. at the beginning and ??? at the end of the error message that gets displayed.

I tried setting the locale for the bean:message and html:messages tag. But did not help.
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With this

<bean:message key="<%=selectError%>"/>

you're asking the tag to use the actual error message as the key. The result you are getting is, in fact, a resource key not found error. You really only need to display the error message text:

<bean:write name="selectError" />
 
M Murthy
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got it working. Found out that there were 2 things wrong with my code.

1) Had to change bean:message to bean:write tag. (Made this change after looking at the example from the struts API doc.)


2) Junilu has found the second mistake. Thanks, that was a good catch.


you're asking the tag to use the actual error message as the key. The result you are getting is, in fact, a resource key not found error. You really only need to display the error message text:


So, the working version is


Changed the id of messages tag to make it less confusing.

Thank y'all for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic