commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [resources]ResourceBundle.getBundle
Date Tue, 18 Mar 2003 17:24:20 GMT


On Tue, 18 Mar 2003, george stewart wrote:

> Date: 18 Mar 2003 09:07:06 -0500
> From: george stewart <gstewart@us-south.net>
> Reply-To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> To: commons-dev@jakarta.apache.org
> Subject: [resources]ResourceBundle.getBundle
>
> In the messages class, there's static method:
>     public static Messages getMessages(String name)
>
> which does this:
> Resources resources = factory.getResources(name + ".LocalStrings");
>
> This doesn't work for ResourceBundle.getBundle on W2K with JDK 1.3.1_04.

The intent is that "name" be the fully qualified package name of the class
that you are in (so that you can localize all the error messages for that
package in a single file).  Struts uses a technique very similar to this
with no problems on Windows, so it would surprise me that this didn't work
(although I don't have a 1.3 JDK on my windows PC to check it right at the
moment).

If you have a reproducible failure case, could you please post it on a bug
report?

  http://nagoya.apache.org/bugzilla/

You can file it against product "Commons" and component "Sandbox" -- just
be sure to include "[Resources]" in the summary description.

>
> You could use name of the form name + "_LocalStrings".
>
> Secondly, wouldn't users prefer an exception in this method instead of
> the silent failure?
>

I don't believe so.

The typical use case is something like this:

  package com.mycompany.mypackage;

  public class MyClass {

    private static Messages messages =
     Messages.getMessages("com.mycompany.mypackage");

    public void myMethod() {
      ...
      if (something bad happened) {
        System.err.println(messages.getMessage("message.key"));
      }
      ...
    }

Having to deal with an exception in the static initializer would be a real
pain.

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message