• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts error message

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this link for help on the same problem.
 
M Murthy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That unwanted stuff usually gets added to the beginning and end of a key that could not be found.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic