/** * Get the properties file factory which loads the properties based on locale and style from * *.properties and *.xml files * * @return properties factory */ protected IPropertiesFactory getPropertiesFactory() { return Application.get().getResourceSettings().getPropertiesFactory(); }
static JSONObject renderResources(final IExtObservable extObservable, Class<?> baseClass) throws JSONException { JSONObject resources = new JSONObject(); IPropertiesFactory propertiesFactory = Application.get().getResourceSettings().getPropertiesFactory(); Session session = Session.get(); String style = session.getStyle(); Locale locale = session.getLocale(); Class<?> clazz = extObservable.getClass(); while (clazz != baseClass) { String path = clazz.getName().replace('.', '/'); ResourceNameIterator iter = new ResourceNameIterator(path, style, null, locale, null, false); while (iter.hasNext()) { String newPath = iter.next(); final Properties props = propertiesFactory.load(clazz, newPath); if (props != null) { ValueMap all = props.getAll(); for (Map.Entry<String, Object> entry : all.entrySet()) { if (!resources.has(entry.getKey())) { resources.put(entry.getKey(), entry.getValue()); } } } } clazz = clazz.getSuperclass(); } return resources; }
/** * Clears all the wicket caches so that resources and localization files will be re-read */ public void clearWicketCaches() { getResourceSettings().getPropertiesFactory().clearCache(); getResourceSettings().getLocalizer().clearCache(); }
@Override protected String load() { // Load the properties associated with the path IPropertiesFactory propertiesFactory = Application.get().getResourceSettings().getPropertiesFactory(); Locale locale = Session.get().getLocale(); String name = location.substring(location.lastIndexOf('/') + 1); ResourceNameIterator iterator = new ResourceNameIterator(location, null, variant, locale, null, false); while (iterator.hasNext()) { String path = iterator.next(); final Properties props = propertiesFactory.load(null, path); if (props != null) { if (variant != null) { // Lookup the value String value = props.getString(name + "_" + variant); if (value != null) { return value; } } String value = props.getString(name); if (value != null) { return value; } } } return name; }