Seam - Load i18n Messages From Database

Posted on February 25, 2009

In some of the JavaEE web applications, it might be a requirement for you, to load internationalization (i18n) messages from database, instead of the usual way of using 'Resource Bundles'. Seam is a pretty good and extensible framework. It provides you an option to override the built-in 'ResourceLoader' functionality and provide your custom logic. Below is the code for the Java class, which extends the Seam's 'ResourceLoader' component and loads i18n messages from the database:

This component is instantiated, only if the user is authenticated, as the annotations show that it depends on the 'Identity' component. Apart from this, in the overridden methods, I'm getting the 'User' component (which holds the logged-in user details, from database) and loading messages from database (for whatever his/her settings are).

Blog Categories
The views expressed on this blog are my personal views and do not reflect the views of my employer or campaigns I am supporting.

All sample code is provided for illustrative purposes only. These examples have not been thoroughly tested under all conditions. The writer therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.