Just checked the code again, the message seems to be shown always (not
just in development mode). To work around this, you can either call
the localizer
without component (as you originally proposed), or you can configure your
logging not to log warnings from the localizer. Just remember that
those warnings
might be useful if you decide later to have per page resource bundles
after all...


2009/4/14 Jonas <[email protected]>:
> Hi,
>
> I don't think createing a ResourceModel instance makes sense, because
> all ResourceModel
> does is using the localizer...
>
> Regarding the original question, if I remember correctly the warning
> message only shows
> up in development mode to give you a heads up that resource lookup
> will not work as
> expected if the component is not yet added to a page.
> See: 
> <http://day-to-day-stuff.blogspot.com/2008/05/wicket-internationalization.html>
> section 'Finding the message'
> If the resource string isn't located in the page's resource file, it's
> probably safe to ignore the warning.
>
> Besides, if you're in a Component, you can use Component#getString as
> shortcut (instead
> of Application.get().getResourceSettings().getLocalizer().getString(...))
>
> cheers,
> Jonas
>
> 2009/4/14 Witold Czaplewski <[email protected]>:
>> Hi Michał,
>>
>> if you need the string of a ResourceModel you may want to call: new
>> ResourceModel("key").getObject().toString().
>>
>> cheers,
>> Witold
>>
>> Am Tue, 14 Apr 2009 11:07:05 +0200
>> schrieb Michał Letyński <[email protected]>:
>>
>>> 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]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to