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?

#23423

Sure, see this example:

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

If the user enters /welcome into the address bar, PrettyFaces intercepts the request and forwards it, so that for JSF it looks like /faces/welcome.xhtml was requested. This is called “inbound rewriting”. But now JSF renders the result page. Each time JSF tries to render /faces/welcome.xhtml to the resulting page, PrettyFaces intercepts this, and changes it back to /welcome. This is called “outbound rewriting”. This is important for example for <h:form>, because it ensures that submitted forms post back to the pretty URL and not to the plain JSF URL.

Now have a look a this example:

<url-mapping id="welcome">
<pattern value="/welcome" />
<view-id value="#{someBean.calculateViewId}" />
</url-mapping>

In this case PrettyFaces calls the dynaview method during inbound rewriting to determine to which URL the request should be forwarded. But outbound rewriting won’t work here because PrettyFaces doesn’t know hat your dynaview methods can return and how to rewrite URLs rendered to the page.

So you CAN use dynaview, but then URLs may turn ugly after postbacks. That’s the reason why I for myself don’t use dynaview at all. It may be useful in some special cases, but typically going with plain mappings is better.

I hope this helps. :)

Christian