face-config default require message override encoding

101 Views Asked by At

i have a multilingual project using various languages and i created a UTF8-Control which i define in my face-config.xml, it's works fine with my .properties files for all language.

then i override javax.faces.component.UIInput.REQUIRED = {0} wird benötigt. in the UI when i need required message in german then i receive name wird benötigt.

this problem only appears when i tried to use the custom messages override like

javax.faces.component.UIInput.CONVERSION javax.faces.converter.DateTimeConverter.DATE_detail

this gave me the impression that my UT8Control is not used in transforming this text (this was also true when i tried debugging)

my UTF8Control class here

public class UTF8Control extends ResourceBundle.Control {
@Override
public ResourceBundle newBundle
    (String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
        throws IllegalAccessException, InstantiationException, IOException
{
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, UTF_8));
        } finally {
            stream.close();
        }
    }
    return bundle;
}

@Override
public Locale getFallbackLocale(String name,
                                        Locale locale) {
    // see super @return description. Return null for no fallback locale
    return null;
}}
0

There are 0 best solutions below