The call to "new StringResourceModel#getString" will use a localized value in the construction of the NavigationItem. The NavigationItem constructor needs to allow an IModel so the localization occurs dynamically.
There is a quote in "Working with Wicket models" [1] that is essentially what that code is doing: "Note that StringResourceModel is dynamic: the property expression is re-evaluated every time getObject() is called. In contrast, if the application code called Localizer itself and used the resulting string as model data, the result would be a static (non-changing) model." Enrique [1] http://cwiki.apache.org/WICKET/working-with-wicket-models.html On Tue, Apr 8, 2008 at 6:00 AM, Milan Křápek <[EMAIL PROTECTED]> wrote: > Hi, > I have another problem with localization. I have stored some names in > database. And I need to get them from database localize them and then render > as some tab menu. > > here is the code: > > HTML: > > <div id="navigation"> > <table border="0" > > <tr ><td wicket:id="navigationlist"> > <a id="link" wicket:id="link">link</a> > </td></tr> > </table> > </div> > > JAVA: > ... > Iterator it = user.getDataCollection().iterator(); > while (it.hasNext()){ > Data d = it.next(); > NavigationItem i = new NavigationItem(new StringResourceModel(d.getName(), > this, null).getString(), d.getUrl()); > navigationList.add(i); > } > add(new ListView("navigationlist", navigationList){ > @Override > public void populateItem (final ListItem listItem){ > final NavigationItem navigationItem = (NavigationItem) > listItem.getModelObject(); > listItem.add(new ExternalLink("link",navigationItem.url, > navigationItem.name)); > } > }); > ... > > When I create new navigation Item I take the right locale name, but when I > change the localization. This items never changed its value. I do not know > why? Please do somebody see where is the problem? > > Thanks for any advice. > > Milan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
