We use a static method to make this work without warning.
public static String getResourceString(final Class clazz, final String
propertyName) {
List<IStringResourceLoader> loaderList =
Application.get().getResourceSettings().getStringResourceLoaders();
for (IStringResourceLoader loader : loaderList) {
String value = loader.loadStringResource(clazz, propertyName, null,
MyOwnSession.get().getStyle());
if (StringUtils.isNotBlank(value)) {
return value;
}
}
return null;
}
Michał Letyński wrote:
>
> Hi.
> When im getting localized string in constructor via getString method the
> warning message is dispalyed: "Tried to retrieve a localized string for
> a component that has not yet been added to the page. "
>
> I know that one possible way to "fix" this is to use
> ResourceModel("key'). But what if i cant use ResourceModel ? for e.g
> some component want String directly. Is there a better solution then
> using:
> "Application.get().getResourceSettings().getLocalizer().getString(resourceKey,
> (Component)null, defaultValue);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
-----
http://ntsrikanth.blogspot.com/
--
View this message in context:
http://www.nabble.com/Getting-localized-string-in-constructor.-tp23035847p23038671.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]