aspose file tools*
The moose likes Struts and the fly likes Struts error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts error message" Watch "Struts error message" New topic
Author

Struts error message

M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
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


Sindhu Murthy<br />SCJP 1.4<br />SCBCD
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Check this link for help on the same problem.
M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
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

Joined: Feb 05, 2003
Posts: 4727

That unwanted stuff usually gets added to the beginning and end of a key that could not be found.


A good workman is known by his tools.
Sujatha Kumar
Ranch Hand

Joined: Jan 05, 2004
Posts: 134
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


SCJP,SCWCD,SCBCD,SCEA Part I
M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
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

Joined: Feb 26, 2001
Posts: 4991
    
    8

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" />


Junilu - [How to Ask Questions] [How to Answer Questions]
M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts error message