igor.vaynberg wrote:
> 
> The problem here is specifying the charset, properties factory is global
> so
> you might encode your files one way but a jar you use with components
> might
> have them encoded in another charset - so we cannot really have a global
> charset specified. i think the proper thing to do is use xml properties
> format where you specify charset/file
> 

I agree with you, Igor. I just didn't know about Java's ability to load
properties from .xml files. I guess this functionality was added to Wicket
1.3, but I use Wicket 1.2.6 in my current project and that's why I still
need to use my patch.
Now I've modified my CustomPropertiesFactory in the following way to accept
.xml properties:

<code>
package wicket.resource;
...
public class CustomPropertiesFactory extends PropertiesFactory {
...
        public CustomPropertiesFactory() {
        }
...
        public Properties get(final Application application, final Class clazz,
                        final String style, final Locale locale) {
...
                if ((props == null) && (getCache().containsKey(key) == false)) {
                        final IResourceStream resource = 
application.getResourceSettings()
                                        
.getResourceStreamLocator().locate(clazz,
                                                        
clazz.getName().replace('.', '/'), style, locale,
                                                        "xml");
...
        }

        private synchronized Properties loadPropertiesFile(final String key,
                        final IResourceStream resourceStream, final Class 
componentClass,
                        final String style, final Locale locale) {
...
                                        properties.loadFromXML(
                                                        new BufferedInputStream(
                                                                        
resourceStream.getInputStream()));
//                                      properties.load(new 
BufferedInputStream(resourceStream
//                                                      .getInputStream()));
...
        }
}
</code>

And its registration looks like this:

<code>
public class EcoApplication extends SpringWebApplication {
...
        @Override
        public final void init() {
                // this line is important
                // for spring-injection through annotations
                addComponentInstantiationListener(new
SpringComponentInjector(this));
// here is the attachment
                getSettings().setPropertiesFactory(new
CustomPropertiesFactory());
        }
} 
</code>
-- 
View this message in context: 
http://www.nabble.com/.properties-encoding-tf4110226.html#a11703594
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to