You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Tzvetanov Grigorov (Jira)" <ji...@apache.org> on 2020/12/09 15:02:00 UTC
[jira] [Assigned] (WICKET-6857) A cloned bug
[ https://issues.apache.org/jira/browse/WICKET-6857?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Tzvetanov Grigorov reassigned WICKET-6857:
-------------------------------------------------
Assignee: Martin Tzvetanov Grigorov
> A cloned bug
> ------------
>
> Key: WICKET-6857
> URL: https://issues.apache.org/jira/browse/WICKET-6857
> Project: Wicket
> Issue Type: Bug
> Reporter: Hao Zhong
> Assignee: Martin Tzvetanov Grigorov
> Priority: Major
>
> I notice that InitializerStringResourceLoader is similar to ValidatorStringResourceLoader. For example, InitializerStringResourceLoader has a loadStringResource method:
> {code:java}
> @Override@Override public String loadStringResource(Class<?> clazz, final String key, final Locale locale, final String style, final String variation) {
> for (IInitializer initializer : initializers) {
> String string = super.loadStringResource(initializer.getClass(), key, locale, style, variation);
> if (string != null) {
> return string;
> }
> }
> }
> {code}
> A previous version of ValidatorStringResourceLoader has a similar method:
> {code:java}
> @Override@Override public String loadStringResource(final Component component, final String key, final Locale locale, final String style, final String variation) {
> if (component == null || !(component instanceof FormComponent)) {
> return null;
> }
> FormComponent<?> fc = (FormComponent<?>)component;
> for (IValidator<?> validator : fc.getValidators()) {
> String resource = loadStringResource(validator.getClass(), key, locale, style, variation);
> if (resource != null) {
> return resource;
> }
> }
> // not found
> return null;
> }
> {code}
> The above method is buggy. https://issues.apache.org/jira/browse/WICKET-4379
> Its fixed code is as folllows:
> {code:java}
> @Override@Override public String loadStringResource(final Component component, final String key, final Locale locale, final String style, final String variation) {
> if (component == null || !(component instanceof FormComponent)) { return null; }
> FormComponent<?> fc = (FormComponent<?>)component;
> for (IValidator<?> validator : fc.getValidators()) {
> Class<?> scope = getScope(validator); String resource = loadStringResource(scope, key, locale, style, variation);
> if (resource != null) {
> return resource;
> }
> }
> // not found
> return null;
> }
> private Class<? extends IValidator> getScope(IValidator<?> validator) {
> Class<? extends IValidator> scope;
> if (validator instanceof ValidatorAdapter) {
> scope = ((ValidatorAdapter) validator).getValidator().getClass();
> } else {
> scope = validator.getClass();
> }
> return scope;
> }
> }
> {code}
> The InitializerStringResourceLoader.loadStringResource can have a similar problem, and shall be checked.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)