You shouldn't be using Map<String, String> - it should be Map<String,
IModel<String>> if you want it to work right.  You're using a "push" method
of coding, pushing your data (strings in this case) into a component prior
to rendering.  This will break down on you when using it in Wicket.  Use a
"pull" method - IOW, get familiar with models.  Try removing the getString()
and refactor your component instantiation (if needed) to take the model
rather than the string.

-- 
Jeremy Thomerson
http://www.wickettraining.com


On Sat, Feb 28, 2009 at 10:25 AM, Stephen Swinsburg <
[email protected]> wrote:

> Hi all,
>
> I have a HashMap I need to localise like so:
>
> LinkedHashMap<String, String> options = new LinkedHashMap<String,
> String>();
> options.put("1", new StringResourceModel(option.1",
> this,null).getString());
> options.put("2", new StringResourceModel("option.2",
> this,null).getString());
> options.put("3", new StringResourceModel("option.3",
> this,null).getString());
>
> But I can't get around this error:
>
> WARN: Tried to retrieve a localized string for a component that has not yet
> been added to the page. This can sometimes lead to an invalid or no
> localized resource returned. Make sure you are not calling
> Component#getString() inside your Component's constructor.
>
> This is being used in a Panel that makes up the content of a ModalWindow.
> When the page loads that contains the ModalWindow, the errors are thrown for
> each getString() call.
>
> The exact same code works on a normal Page (ie not in a ModalWindow).
> Anyone know what is up/how to get around it? It does actually work fine, ie
> it renders as normal.
>
>
> Wicket 1.3.5
>
>
> cheers,
> Steve
>
>

Reply via email to