use of ognl.NoSuchPropertyException in project dhis2-core by dhis2.
the class I18nInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Action action = (Action) invocation.getAction();
I18n i18n = i18nManager.getI18n(action.getClass());
I18nFormat i18nFormat = i18nManager.getI18nFormat();
Locale locale = localeManager.getCurrentLocale();
// ---------------------------------------------------------------------
// Make the objects available for web templates
// ---------------------------------------------------------------------
Map<String, Object> i18nMap = new HashMap<>(3);
i18nMap.put(KEY_I18N, i18n);
i18nMap.put(KEY_I18N_FORMAT, i18nFormat);
i18nMap.put(KEY_LOCALE, locale);
invocation.getStack().push(i18nMap);
// ---------------------------------------------------------------------
// Set the objects in the action class if the properties exist
// ---------------------------------------------------------------------
Map<?, ?> contextMap = invocation.getInvocationContext().getContextMap();
try {
Ognl.setValue(KEY_I18N, contextMap, action, i18n);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_I18N_FORMAT, contextMap, action, i18nFormat);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_LOCALE, contextMap, action, locale);
} catch (NoSuchPropertyException ignored) {
}
return invocation.invoke();
}
Aggregations