You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hartmut Bernecker <h....@dhw.de> on 2001/07/19 20:18:19 UTC

Is there a way to localize error-messages produced by the system?

Hi,

I have no idea how to localize errors produced by the system itselfe.

- There is no problem for me to localize the Struts-Application with
localized property files (labels, buttons, validation errors of forms
etc.).

But now an example where I don't know how to do:
A login action checks if the connection to the backend server is ok.
If not then I populate a special special error-bean in the session with
an error message to be shown:

<bean:write name="asimerror" property="error"/>

That is no problem. But how can I localize that System-Error-Message???

I thougt about using a error-key (like:
login.error.label.noserverconnection) within a JSP element like:

<bean:message key="login.error.label.noserverconnection"/>

But I don't know how to put the login.error.label.noserverconnection"
dynamically in that line of code ...



TIA for your ideas!
Hartmut

Re: Is there a way to localize error-messages produced by the system?

Posted by Peter Alfors <pe...@irista.com>.
One option:
When you trap an error, look up the i18n text for that specific error.
Then place the translated text in your error bean.
Your page can then use the format:

<bean:write name="asimerror" property="error"/>

For example, when you trap the exception that you were unable to connect to
the database, lookup
"login.error.label.noserverconnection" and place the translated text in the
error bean.

HTH,
    Pete

Hartmut Bernecker wrote:

> Hi,
>
> I have no idea how to localize errors produced by the system itselfe.
>
> - There is no problem for me to localize the Struts-Application with
> localized property files (labels, buttons, validation errors of forms
> etc.).
>
> But now an example where I don't know how to do:
> A login action checks if the connection to the backend server is ok.
> If not then I populate a special special error-bean in the session with
> an error message to be shown:
>
> <bean:write name="asimerror" property="error"/>
>
> That is no problem. But how can I localize that System-Error-Message???
>
> I thougt about using a error-key (like:
> login.error.label.noserverconnection) within a JSP element like:
>
> <bean:message key="login.error.label.noserverconnection"/>
>
> But I don't know how to put the login.error.label.noserverconnection"
> dynamically in that line of code ...
>
> TIA for your ideas!
> Hartmut