Re: multi-language url rewiting. Is it possible?

Splash Forums PrettyFaces Users multi-language url rewiting. Is it possible? Re: multi-language url rewiting. Is it possible?

#23421

Sure, you can embed the language code into the URL. I would try something like this:

<url-mapping id="base">
<pattern value="/#{localeBean.currentLang}" />
</url-mapping>

<url-mapping id="welcome" parentId="base">
<pattern value="/welcome" />
<view-id value="/faces/welcome.xhtml" />
</url-mapping>

This way you will get an URL like http://someserver/en/welcome which will automatically set the language code in your bean responsible for the language.

The localeBean in this example IMHO shouldn’t have session scope but request scope, because the language is embedded in each URL and therefore it is automatically set on each request.