[nbj2ee] How do I access resource bundles from the application?

  • From: "janpla" < >
  • To:
  • Subject: [nbj2ee] How do I access resource bundles from the application?
  • Date: Tue, 26 Jun 2012 09:30:59 -0400

I have created two resource bundles in my app; both are in a folder called 
webrc; this is how I specify them in my faces-config.xml:


Code:

  <application>
    <resource-bundle>
      <base-name>webrc.labels</base-name>
      <var>labels</var>
    </resource-bundle>
    <resource-bundle>
      <base-name>webrc.staferror</base-name>
      <var>staferror</var>
    </resource-bundle>
  </application>




One of them, "labels", I use from JSF pages, and it works fine. The other 
one, "staferror", I try to call from a class:


Code:

public class StafError {
...
    public static String getErrorText(int errno){
        String etxt;

        ResourceBundle res=ResourceBundle.getBundle("staferror");
        etxt=res.getString(getErrNm(errno));
        return etxt;
    }
}




This fails with an exception:


Code:

Caused by: java.util.MissingResourceException: Can't find bundle for base 
name staferror, locale en_US
        at 
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
        at stafutil.StafError.getErrorText(StafError.java:255)
        at stafcmds.StafSession.executecmd(StafSession.java:49)




- which is just at the ResourceBundle 
res=ResourceBundle.getBundle("staferror"); in the code above. How should I 
refer to this bundle in this call?






[nbj2ee] How do I access resource bundles from the application?

janpla 06/26/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close