0

Spring Webflow 2.5.1.

I have my own implementation of ReloadableResourceBundleMessageSource. I can successfully establish it in Spring MVC via:


    @Bean
    public ReloadableResourceBundleMessageSource messageSource() {
        ReloadableResourceBundleMessageSource source = new AwareReloadableResourceBundleMessageSource();
        source.setCacheSeconds(cacheSeconds);
        source.setBasename("WEB-INF/i18n/messages");
        source.setUseCodeAsDefaultMessage(true);
        source.setDefaultEncoding("UTF-8");
        return source;
    }

My application uses both Spring MVC and Webflow.

I would like to have instances of the same AwareReloadableResourceBundleMessageSource in place for the individual per-flow messages.properties files.

I have tried:

@Configuration
public class WebFlowConfig extends AbstractFlowConfiguration {
  ...


    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource ms = new AwareReloadableResourceBundleMessageSource();
        ms.setBasename("messages");

        System.out.println("MESSAGE SOURCE AwareReloadableResourceBundleMessageSource");
        return ms;
    }
}

But the messageSource() method is not called.

I have seen: https://stackoverflow.com/a/8126164

Any pointers/techniques/code snipppets very gratefully accepted.

Bob Brown
  • 930
  • 2
  • 7
  • 14

1 Answers1

0

Try the following:

  1. Configure messageSource() within a ValidatorFactory bean, AND

  2. Configure the ValidatorFactory bean within FlowBuilderServices

    @Bean public FlowBuilderServices flowBuilderServices() { return getFlowBuilderServicesBuilder() .setValidator(getValidator()) .build(); }

    @Bean public LocalValidatorFactoryBean getValidator() { LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean(); bean.setValidationMessageSource(messageSource()); return bean; }

sree
  • 1
  • Thanks for the suggestion @sree. Sadly that didn't work for me. Hmmm. I note the doco for LocalValidatorFactoryBean says with Spring 5, it "requires Bean Validation 1.1+". I have hibernate validator 6.1.5.FINAL. So should be good, but still. LUCKILY, I do all my UI messaging via a single custom tag and can tweak that to do the post-processing I need. A shame, though... – Bob Brown Apr 16 '21 at 06:00