You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ralf Eichinger <ra...@pixotec.de> on 2010/02/28 19:19:39 UTC

Bugs in PropertiesFactory?

loading my own properties-file with PropertiesFactory (1.4.6) does not work:

placed "myfile.properties" in "com.mycompany.webapp" (where also 
MyApplication.java resides) and wanted to load it
in the init()-method of MyApplication with:

PropertiesFactory propertiesFactory = new PropertiesFactory(this);
Properties myProps = propertiesFactory.load(getClass(), "myfile");

Bug 1:
PropertiesFactory.load():

/**
          *
          * @see 
org.apache.wicket.resource.PropertiesFactory.IPropertiesLoader#load(java.lang.Class,
          *      java.lang.String)
          */
         public Properties load(final Class<?> clazz, final String path)
         {
             String fullPath = path + getFileExtension();

produces: myfileproperties
so should be corrected to:

         public Properties load(final Class<?> clazz, final String path)
         {
             String fullPath = path + "." + getFileExtension();



Bug 2: seems that "clazz" is not taken into account...
Is not searching in com.mycompany.webapp!
Workaround: I placed the file in root of classpath...

Should I create a JIRA entry or am I doing something wrong?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Bugs in PropertiesFactory?

Posted by Igor Vaynberg <ig...@gmail.com>.
On Sun, Feb 28, 2010 at 10:19 AM, Ralf Eichinger
<ra...@pixotec.de> wrote:
> loading my own properties-file with PropertiesFactory (1.4.6) does not work:
>
> placed "myfile.properties" in "com.mycompany.webapp" (where also
> MyApplication.java resides) and wanted to load it
> in the init()-method of MyApplication with:
>
> PropertiesFactory propertiesFactory = new PropertiesFactory(this);
> Properties myProps = propertiesFactory.load(getClass(), "myfile");
>
> Bug 1:
> PropertiesFactory.load():
>
> /**
>         *
>         * @see
> org.apache.wicket.resource.PropertiesFactory.IPropertiesLoader#load(java.lang.Class,
>         *      java.lang.String)
>         */
>        public Properties load(final Class<?> clazz, final String path)
>        {
>            String fullPath = path + getFileExtension();
>
> produces: myfileproperties
> so should be corrected to:
>
>        public Properties load(final Class<?> clazz, final String path)
>        {
>            String fullPath = path + "." + getFileExtension();

your path should contain the trailing "."

> Bug 2: seems that "clazz" is not taken into account...
> Is not searching in com.mycompany.webapp!

the class is taking into account, see
AbstractPropertiesLoader#load(clazz,string)

propertiesfactory is meant to be used by wicket, not directly by you.
so you have to conform to how it works if you want to use it directly.
i suggest you set a breakpoint and walk through the code to see where
it goes wrong for you.

-igor


> Workaround: I placed the file in root of classpath...
>
> Should I create a JIRA entry or am I doing something wrong?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org