How to use the Liferay Language Setting in a JSF / ICEFaces Portlet

Problem: JSF or ICEFaces Portlet don´t really seem to care for the language settings of Liferay. They always take the language properties from the browser. That´s ok, but sometimes you want to force a certain language. This is what you can do:

Create a Bean returning the Liferay Language

public class LocaleBean{
    public Locale getLocale() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ThemeDisplay themeDisplay =       
        return themeDisplay.getLocale();

This Bean returns the locale set for the current User.

Initialize your JSF Page 

Now, initialize your JSF page like this:

<f:view  locale="#{localeUtil.locale}">

If you liked this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.