struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alireza Fattahi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4829) Set a global resource bundle in class
Date Mon, 31 Jul 2017 12:44:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16107263#comment-16107263
] 

Alireza Fattahi commented on WW-4829:
-------------------------------------

Can you please help me with this too:

Here is the code:

{code:java}
public class CustomStrutsTextProviderFactory extends StrutsTextProviderFactory {
	
	@Override
	protected TextProvider getTextProvider(Class clazz) {
               localizedTextProvider.addDefaultResourceBundle("messages/label");
		localizedTextProvider.addDefaultResourceBundle("messages/customerA/label");
		return new CustomTextProvider(clazz, localeProviderFactory.createLocaleProvider(), localizedTextProvider);
      }

{code}

The code works, but for every request the *CustomStrutsTextProviderFactory.getTextProvider*
is called. So the *localizedTextProvider.addDefaultResourceBundle* is called for every request.
Although the   *AbstractLocalizedTextProvider.addDefaultResourceBundle* make sure bundle is
not doesn't get added more than once ... I think the *CustomStrutsTextProviderFactory* could
be write better.

> Set a global resource bundle in class 
> --------------------------------------
>
>                 Key: WW-4829
>                 URL: https://issues.apache.org/jira/browse/WW-4829
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.5.12
>            Reporter: Alireza Fattahi
>             Fix For: 2.5.13
>
>
> In struts 2.5.12 the *LocalizedTextUtil* is removed.
> We used to `*LocalizedTextUtil.addDefaultResourceBundle*` in our classes to add resource
bundles. This was mentioned in https://struts.apache.org/docs/how-do-i-set-a-global-resource-bundle.html
> Can you please let me know how this can be done with this change ?!



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message