Hi,
I am trying to implement a database driven resource bundle and am searching for the best implementation. I have the requirement to change the web page text based on the language and also what user has logged in. I'd like to access my resource bundle from my action classes as well as my JSP pages. My application uses struts 2 and spring 2.5.6.
Spring is set up for annotation based configuration.
My current implementation is as follows.
Then on my JSPCode:@Component public class CoreDatabaseResourceBundle extends ListResourceBundle { @Autowired private TranslationService translationService; private Locale locale; private String moduleName; private Object[][] contents; @PostConstruct public void initialise() { contents = this.translationService.getTranslations(this.moduleName, this.locale); } @Override public Object[][] getContents(){ return contents; } // other getters and setters omitted }
When i debug the code the resource bundle initialises okay so the annotations are working. However when the JSP creates an instance of the resource bundle it does not do it via spring hence my translation service is null.Code:<fmt:setLocale scope="page" value="en" /> <fmt:setBundle basename="com.example.CoreDatabaseResourceBundle"/> <fmt:message key="test.message"/>
Any pointers how to fix my current implementaion or pointers to a better more 'spring' way of implemention this is appreciated!
Thanks


Reply With Quote