You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Niniva Ray <ni...@yahoo.com> on 2006/08/05 02:07:59 UTC
Need help in how to display error messages
Hi,
I am working on a web application where I am using struts 1.2.9.
The problem I am encountering is whenever I want to show any messages on the browser, suppose if I want to show the message "Error saving configuration",
it is displaying ???en_US.Error saving configuration???
The details of what I have are
In my struts-config file I have
<message-resources parameter="com.mng.filemanagement.resources.FileManagementResources" null="false"/>
I have FileManagementResources.properties file in the com.mng.filemanagement.resources package.
In this properties file I have the entry,
error.message.filemanagement.errorsavingconfiguration=Error saving configuration
In my Action class I have,
MessageResources messageResources = getResources(request); // request is HttpServletRequest
ActionMessage error = new ActionMessage(messageResources.getMessage("error.message.filemanagement.errorsavingconfiguration"));
ActionMessages errors = new ActionMessages();
errors.add(FileManagementConstants.ERROR_KEY, error); // FileManagementConstants.ERROR_KEY is a string with value error
addErrors(request, errors);
In my jsp page I have
<logic:messagesPresent property="error">
<html:messages id="message" property="error">
<bean:write name="message"/><br>
</html:messages>
</logic:messagesPresent>
This displays ???en_US.Error saving configuration???
when error happens, instead of Error saving configuration.
I am supporting only one language English.
I think I am missing something, could anyone give me some pointers what I am doing wrong?
Thanks,
NR
---------------------------------
See the all-new, redesigned Yahoo.com. Check it out.
Re: Need help in how to display error messages
Posted by Niniva Ray <ni...@yahoo.com>.
Hi Niall,
Thank you for the suggestion and explanation.
It worked.
Thanks,
Niniva
Niall Pemberton <ni...@gmail.com> wrote:
The reason this is happening is because (normally) your ActionMessage
contains the key - and then the tag looks up the
actual message (i.e. "resolves the message") - but you're actually
resolving the message yourself in the Action.
Try just creating the ActionMessage with the key:
ActionMessage error =
new ActionMessage("error.message.filemanagement.errorsavingconfiguration");
Niall
On 8/5/06, Niniva Ray wrote:
> Hi,
>
> I am working on a web application where I am using struts 1.2.9.
> The problem I am encountering is whenever I want to show any messages on the browser, suppose if I want to show the message "Error saving configuration",
> it is displaying ???en_US.Error saving configuration???
>
> The details of what I have are
> In my struts-config file I have
>
>
> I have FileManagementResources.properties file in the com.mng.filemanagement.resources package.
>
> In this properties file I have the entry,
> error.message.filemanagement.errorsavingconfiguration=Error saving configuration
>
> In my Action class I have,
> MessageResources messageResources = getResources(request); // request is HttpServletRequest
> ActionMessage error = new ActionMessage(messageResources.getMessage("error.message.filemanagement.errorsavingconfiguration"));
> ActionMessages errors = new ActionMessages();
> errors.add(FileManagementConstants.ERROR_KEY, error); // FileManagementConstants.ERROR_KEY is a string with value error
> addErrors(request, errors);
>
> In my jsp page I have
>
>
>
>
>
>
> This displays ???en_US.Error saving configuration???
> when error happens, instead of Error saving configuration.
>
> I am supporting only one language English.
> I think I am missing something, could anyone give me some pointers what I am doing wrong?
>
> Thanks,
> NR
>
>
> ---------------------------------
> See the all-new, redesigned Yahoo.com. Check it out.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs.Try it free.
Re: Need help in how to display error messages
Posted by Niall Pemberton <ni...@gmail.com>.
The reason this is happening is because (normally) your ActionMessage
contains the key - and then the <html:messages> tag looks up the
actual message (i.e. "resolves the message") - but you're actually
resolving the message yourself in the Action.
Try just creating the ActionMessage with the key:
ActionMessage error =
new ActionMessage("error.message.filemanagement.errorsavingconfiguration");
Niall
On 8/5/06, Niniva Ray <ni...@yahoo.com> wrote:
> Hi,
>
> I am working on a web application where I am using struts 1.2.9.
> The problem I am encountering is whenever I want to show any messages on the browser, suppose if I want to show the message "Error saving configuration",
> it is displaying ???en_US.Error saving configuration???
>
> The details of what I have are
> In my struts-config file I have
> <message-resources parameter="com.mng.filemanagement.resources.FileManagementResources" null="false"/>
>
> I have FileManagementResources.properties file in the com.mng.filemanagement.resources package.
>
> In this properties file I have the entry,
> error.message.filemanagement.errorsavingconfiguration=Error saving configuration
>
> In my Action class I have,
> MessageResources messageResources = getResources(request); // request is HttpServletRequest
> ActionMessage error = new ActionMessage(messageResources.getMessage("error.message.filemanagement.errorsavingconfiguration"));
> ActionMessages errors = new ActionMessages();
> errors.add(FileManagementConstants.ERROR_KEY, error); // FileManagementConstants.ERROR_KEY is a string with value error
> addErrors(request, errors);
>
> In my jsp page I have
> <logic:messagesPresent property="error">
> <html:messages id="message" property="error">
> <bean:write name="message"/><br>
> </html:messages>
> </logic:messagesPresent>
>
> This displays ???en_US.Error saving configuration???
> when error happens, instead of Error saving configuration.
>
> I am supporting only one language English.
> I think I am missing something, could anyone give me some pointers what I am doing wrong?
>
> Thanks,
> NR
>
>
> ---------------------------------
> See the all-new, redesigned Yahoo.com. Check it out.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org