Not sure what you mean about implementing a unique class... any class which
inherits from Component can call getString(String key), which will call your
custom IStringResourceLoader. Additionally, you can set the locale on any
MarkupContainer or the Session, and Components will use their parent's
locale falling back to the Session's.
You can also use the wicket:message tag directly in your markup, which uses
whatever locale it's associated class uses.
What we do is set the locale on the Session, and use that and a resource key
to pull the string from the database. We use DB caching, and turn off the
built-in resource string caching that wicket does (see below, goes in
WebApplication.init()).
getResourceSettings().setLocalizer(new Localizer() {
@Override
protected void putIntoCache(String cacheKey, String string) {
// Do nothing... no caching desired, since our DB layer caches
}
});
On Tue, Apr 20, 2010 at 1:53 PM, Zilvinas Vilutis <[email protected]> wrote:
> Yes,
>
> That seems to work. Although each component which needs to be
> localized needs to implement a unique class, 'cause in many cases the
> Component class is "WebMarkupContainer" ( if we use components in list
> & etc ).
>
> Does anyone have practice on using any performance experience on that?
>
> Do you use DB caching or method caching?
>
>
> Žilvinas Vilutis
>
> Mobile: (+370) 652 38353
> E-mail: [email protected]
>
>
>
> On Tue, Apr 20, 2010 at 7:40 AM, Josh Glassman <[email protected]> wrote:
> > Yup, you have the right idea.
> >
> > Something like...
> > public class DatabaseStringResourceLoader implements
> > IStringResourceLoader {...}
> >
> > And then in your WebApplication.init()...
> > getResourceSettings().addStringResourceLoader(new
> > DatabaseStringResourceLoader());
> >
> > Cheers,
> > Josh
> >
>