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

Alireza Fattahi edited comment on WW-4829 at 7/31/17 12:44 PM:
---------------------------------------------------------------

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 it is not a good approch 
... 

I think the *CustomStrutsTextProviderFactory* could be write better, any idea!


was (Author: afattahi):
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)

Reply via email to