Re: SEO URL supporting l10n/i18n with PrettyFaces

Splash Forums PrettyFaces Users SEO URL supporting l10n/i18n with PrettyFaces Re: SEO URL supporting l10n/i18n with PrettyFaces



I think there are a few ways to achieve what you want. The first idea is to introduce a parent mapping for all your existing mappings that includes the language code. Something like this:

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

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

and a bean like this:

public class LocaleBean {

private String languageCode;

/* getters / setters */

public Locale getLocale() {
return new Locale(languageCode);


And a view configuration like this:

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

I think think this setup will work fine. The only problem will be, that you will have to adjust all your <pretty:link> and <h:link> components to include the value of the lang parameter. Something like this:

<pretty:link mappingId="welcome">
<f:param value="#{localBean.lang}">


<h:link outcome="/welcome.xhtml">
<f:param name="lang" value="#{localBean.lang}" />

If you are looking for a simpler solution, you should have a look at Rewrite, which is the successor of PrettyFaces. I think it could be possible to implement something like this so that you won’t have to adjust much code. But I’m not completely sure how this would look like. But with Rewrite you can do EVERYTHING. :)

Have a look here:


and especially: