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 Grigorov (JIRA)" <ji...@apache.org> on 2017/06/13 19:16:00 UTC

[jira] [Commented] (WICKET-6393) NestedStringResourceLoader ignores hard-coded default values and throws MissingResourceException

    [ https://issues.apache.org/jira/browse/WICKET-6393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048271#comment-16048271 ] 

Martin Grigorov commented on WICKET-6393:
-----------------------------------------

The only way to fix this is to change the API of org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(org.apache.wicket.Component, java.lang.String, java.util.Locale, java.lang.String, java.lang.String) in Wicket 8.x. We should add IModel<String> for the default value.
Maybe even to both methods in this class.

@devs: What do you think ? 

> NestedStringResourceLoader ignores hard-coded default values and throws MissingResourceException
> ------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-6393
>                 URL: https://issues.apache.org/jira/browse/WICKET-6393
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.7.0
>            Reporter: Richard Eckart de Castilho
>            Assignee: Martin Grigorov
>
> The NestedStringResourceLoader ignores hard-coded default values and throws a MissingResourceException.
> Consider FormComponen.getString()
> {noformat}
> 		private String getString(Localizer localizer, String key, Component component)
> 		{
> 			triedKeys.add(key);
> 			// Note: It is important that the default value of "" is
> 			// provided to getString() not to throw a MissingResourceException or to
> 			// return a default string like "[Warning: String ..."
> 			return localizer.getString(key, component, "");
> 		}
> {noformat}
> The default value provided here actually gets lost in the call hierarchy in `Localizer.getString()` (line 232). That seems to be ok because the code there seems to expect that any code it calls will not take into account the `ThrowExceptionOnMissingResource` setting (at least that is what I infer from the method name `getStringIgnoreSettings`. However, again further down the hierarchy, `NestedStringResourceLoader.handleMissingKey()` (line 166) is called which throws a MissingResourceException and defies the default-value handling code in `Localizer.getString()`.
> Here is a stack trace:
> {noformat}
> NestedStringResourceLoader.handleMissingKey(String, Locale, String, Component, String) line: 186	
> NestedStringResourceLoader.loadNestedStringResource(Object, String, Locale, String, String) line: 130	
> NestedStringResourceLoader.loadStringResource(Component, String, Locale, String, String) line: 79	
> Localizer.getStringIgnoreSettings(String, Component, IModel<?>, Locale, String, String) line: 397	
> Localizer.getString(String, Component, IModel<?>, Locale, String, IModel<String>) line: 232	
> Localizer.getString(String, Component, IModel<?>, Locale, String, String) line: 201	
> Localizer.getString(String, Component, String) line: 150	
> FormComponent$MessageSource.getString(Localizer, String, Component) line: 201	
> FormComponent$MessageSource.getMessage(String, Map<String,Object>) line: 138	
> ValidationError.getErrorMessage(IErrorMessageSource) line: 230	
> TextField<T>(FormComponent<T>).error(IValidationError) line: 657	
> TextField<T>(FormComponent<T>).reportRequiredError() line: 1488	
> TextField<T>(FormComponent<T>).validateRequired() line: 1479	
> TextField<T>(FormComponent<T>).validate() line: 1127	
> ...
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)