You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Hasnain Badami <ha...@gmail.com> on 2006/05/16 17:19:49 UTC
Problem loading a resource bundle
Hi
I have a .properties file defined in my project in which I have messages of
my application. I am using the following code to load the bundle in my
application
ArrayList<Cell> valueBindedArrayList = new ArrayList<Cell>();
String bundleName = fc.getApplication().getMessageBundle();
System.out.println("bundle name is " + bundleName);
Locale locale = fc.getApplication().getDefaultLocale();
ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
But on executing the system print shows that the bundle name is null. Can
there be any configuration problems. The properties file is in a package
called resource.
Any help shall be highly appreciated
Thanks
Hassnain
Re: Problem loading a resource bundle
Posted by Hasnain Badami <ha...@gmail.com>.
Thanks ould
On 5/16/06, ould neman <no...@emn.fr> wrote:
>
> Hasnain Badami a écrit :
> > Hi
> >
> > I have a .properties file defined in my project in which I have
> > messages of my application. I am using the following code to load the
> > bundle in my application
> >
> > ArrayList<Cell> valueBindedArrayList = new ArrayList<Cell>();
> > String bundleName = fc.getApplication().getMessageBundle();
> > System.out.println("bundle name is " + bundleName);
> > Locale locale = fc.getApplication().getDefaultLocale();
> > ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
> >
> > But on executing the system print shows that the bundle name is null.
> > Can there be any configuration problems. The properties file is in a
> > package called resource.
> >
> > Any help shall be highly appreciated
> >
> > Thanks
> >
> > Hassnain
> I use this code and I get my resource bundle
>
> FacesContext fc = FacesContext.getCurrentInstance();
> ResourceBundle f = ResourceBundle.getBundle(fc.getApplication()
> .getMessageBundle(), fc.getViewRoot().getLocale());
>
> but you must put this code in your faces-config.xml :
> <application>
> <locale-config>
> <default-locale>fr</default-locale>
> <supported-locale>fr</supported-locale>
> <supported-locale>en_US</supported-locale>
> <supported-locale>de</supported-locale>
> </locale-config>
> <message-bundle>folder1.folder2.authentification</message-bundle>
> </application>
>
> good luck
>
Re: Problem loading a resource bundle
Posted by ould neman <no...@emn.fr>.
Hasnain Badami a écrit :
> Hi
>
> I have a .properties file defined in my project in which I have
> messages of my application. I am using the following code to load the
> bundle in my application
>
> ArrayList<Cell> valueBindedArrayList = new ArrayList<Cell>();
> String bundleName = fc.getApplication().getMessageBundle();
> System.out.println("bundle name is " + bundleName);
> Locale locale = fc.getApplication().getDefaultLocale();
> ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
>
> But on executing the system print shows that the bundle name is null.
> Can there be any configuration problems. The properties file is in a
> package called resource.
>
> Any help shall be highly appreciated
>
> Thanks
>
> Hassnain
I use this code and I get my resource bundle
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle f = ResourceBundle.getBundle(fc.getApplication()
.getMessageBundle(), fc.getViewRoot().getLocale());
but you must put this code in your faces-config.xml :
<application>
<locale-config>
<default-locale>fr</default-locale>
<supported-locale>fr</supported-locale>
<supported-locale>en_US</supported-locale>
<supported-locale>de</supported-locale>
</locale-config>
<message-bundle>folder1.folder2.authentification</message-bundle>
</application>
good luck