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

#23445

Meanwhile I could test the version using PrettyFaces and in principle it works as it should with the configuration as follows:

<!-- lang -->

<url-mapping id="lang">

<pattern value="/#{languageSelected : localeHandler.languageSelected}" />

</url-mapping>

<!-- welcome -->

<url-mapping id="welcome">

<pattern value="/"/>

<view-id value="/pages/index.xhtml"/>

</url-mapping>

<!-- home -->

<url-mapping parentId="lang" id="home">

<pattern value="/"/>

<view-id value="/pages/index.xhtml"/>

</url-mapping>

<!-- company -->

<url-mapping parentId="lang" id="company">

<pattern value="/company"/>

<view-id value="/pages/company.xhtml"/>

</url-mapping>

<h:link value="Home"

outcome="/pages/index">

<f:param name="languageSelected" value="#{localeHandler.languageSelected}"/>

</h:link>

<h:link value="Company"

outcome="/pages/company">

<f:param name="languageSelected" value="#{localeHandler.languageSelected}"/>

</h:link>

Examples of the resulting URL are:

http://localhost:8080

http://localhost:8080/en/

http://localhost:8080/en/company

There are two little drawbacks.

  1. The mapping “lang” becomes highlighted by the IDE (IntelliJ IDEA) and a error message becomes shown as follows:

    “The content of element “url-mapping” is not complete. One of ‘{“http://ocpsoft.com/prettyfaces/3.3.3”:query-param, “http://ocpsoft.vom/prettyfaces/3.3.3″:view-id}” is expected.”

  2. It’s a lot of work to equip each h:link with <f:param name="languageSelected" value="#{localeHandler.languageSelected}"/>
  3. However, if it works it would be worth to do the effort.

    In that case, is there a chance to get rid of the trailing “/” in case of http://localhost:8080/en/ for the localized welcome page?

    Now I’m curious about trying the version with Rewrite.

    Kind regards

    Stephan Rudolph