tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Luehe <Jan.Lu...@Sun.COM>
Subject I18N: <exception> tag (was: Re: I18N: <bundle> Bug?)
Date Thu, 20 Dec 2001 00:58:42 GMT
> The usual thing to do with exceptions in a i18n environment is to throw a
> code for the message, not the actual message.  Then you just use the code as
> a key to look up the localized message in a properties file.  This way
> there's no need to use any custom exceptions.

In the approach you are describing, the code (or key) of the exception message
is looked up in the application's configured resource bundle, and the
message it maps to is passed into the exception's constructor before the
exception is thrown, like this:

  throw new XXXException(Resources.getMessage("SOME_ERROR_CODE")); 

However, in the environment the i18n tags are concerned with, the
locale in which to display the exception message is set by the
page author or determined dynamically (if browser-sensing capabilites for
locales are enabled) and will be different from the locale of the application's
configured resource bundle. In most cases, the application code throwing the
exception is not aware of the (page's) target locale and therefore can not
(and should not) determine any localized strings.

This is the responsibility of the <exception> tag, which allows exception
messages to be localized to the page's locale.


Jan


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message