2017-06-25 8:07 GMT+02:00 i...@flyingfischer.ch <i...@flyingfischer.ch>:
> I get stuck with the refactored LocalizedTextUtil:
>
> We had a change in 2.5.2 which disallowed the use of getText(String key)
> in classes that cannot extend ActionSupport.
>
> I did work around with a custom utility class that did the job, built
> mainly around:
>
> final String value = LocalizedTextUtil.findDefaultText(key, getLocale());
>
> This does not work anymore. What is the present correct way to get this
> working? Is there any documentation for this?

LocalizedTextUtil was converted into a bean, the LocalizedTextProvider
- an interface with two implementations. You can use them by defining
a setter and annotating it with @Inject (like for other Struts beans)

@Inject
public void setLocalizedTextProvider(LocalizedTextProvider
localizedTextProvider) {
    this.localizedTextProvider = localizedTextProvider;
}

This will inject an implementation which behaves the same as
LocalizedTextUtil, it will scan hierarchy (but just once) to localise
proper resource bundles.

The second implementation based just on the global properties defined
with "struts.custom.i18n.resources" and you can use it by adding a
name to the @Inject

@Inject("global-only")
public void setLocalizedTextProvider(LocalizedTextProvider
localizedTextProvider) {
    this.localizedTextProvider = localizedTextProvider;
}


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org

Reply via email to