struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Brin <>
Subject Issues with Localization changes in 2.5.12
Date Thu, 13 Jul 2017 18:08:14 GMT
  With the removal of the TextProviderFactory and it’s replacement with beans, I can’t
figure out how to properly setup our test environment (when testing Controllers that are autowired
by spring.  How do I inject a custom resourceBundle into the ActionContext or stack?  I used
to be able to create my own textProvider, but this no longer works.    I’ve seen code like
the following in the struts2 tests, but localizedTextProvider is null here:

        LocalizedTextProvider localizedTextProvider = container.getInstance(LocalizedTextProvider.class);

I think if I can get the localizedTextProvider properly installed into the container, I’d
be fine, but I can’t see how to do that. Here’s our setup code that worked with Struts

   T controller = applicationContext.getBean(controllerClass);
        if (controller instanceof AbstractAuthenticatableAction) {
            TdarActionSupport tas = (TdarActionSupport) controller;
            // set the context
        Map<String, Object> contextMap = new HashMap<String, Object>();
        contextMap.put(StrutsStatics.HTTP_REQUEST, getServletRequest());
        ActionContext context = new ActionContext(contextMap);

        ConfigurationManager configurationManager = new ConfigurationManager();
        OgnlValueStackFactory factory = new OgnlValueStackFactory();

        // FIXME: needs to be a better way to handle this
        TextProviderFactory textProviderFactory = new TextProviderFactory();

        factory.setTextProvider(textProviderFactory.createInstance(getResourceBundle(), (LocaleProvider)

        configurationManager.addContainerProvider(new XWorkConfigurationProvider());
        if (controller instanceof ActionSupport) {
            ((ActionSupport) controller).setContainer(configurationManager.getConfiguration().getContainer());
        ValueStack stack = factory.createValueStack();

Adam Brin
Director of Technology, Digital Antiquity

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message