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?

#23426

francescanye
Member

I’ve installed pretty-faces very quickly, that’s very nice.

I’ve just used this configuration for my project and I experienced behaviours I was not expected.

I’m trying with my eclipse project which adds the context “mtc” which will not be there on production (where the web app is on root of jetty server).

This is the configuration:

<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/prettyfaces/3.3.3
http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">

<url-mapping id="base">
<pattern value="/#{localeChanger.languageCode}/main" />
</url-mapping>
<url-mapping id="welcome" parentId="base">
<pattern value="/welcome" />
<view-id value="/pages/main/welcome.jsf" />
</url-mapping>

</pretty-config>

In the web.xml:

<welcome-file-list>
<welcome-file>pages/main/welcome.jsf</welcome-file>
</welcome-file-list>

and the pretty-faces filter is the first one configured as in the documentation.

Here is the behaviour:

1) when I enter http://localhost:8080/mtc/ the browser displays the default page

http://localhost:8080/mtc/pages/main/welcome.jsf (I expected http://localhost:8080/mtc/it/main/welcome instead, is there a way to fulfill my use case?)

2) in this page there is a link to itself: the link (out-bound request, as far as I understand) navigates to tha same url

http://localhost:8080/mtc/pages/main/welcome.jsf (I expected again http://localhost:8080/mtc/it/main/welcome. As I’m not using dynaview, why out-bound does not work? )

3) when I enter http://localhost:8080/mtc/en/main/welcome the mapping works well and the page is displayed (in-bound request)

4) in this situation the link to the same page returns

http://localhost:8080/mtc/pages/main/welcome.jsf (instead of http://localhost:8080/mtc/en/main/welcome, why?)

So, to be clearer, I would like to have the following behaviour:

1) the user types

1.a – http://localhost:8080/mtc/ (in my development environment) or

1.b – http://www.mydomain.com/ (in production)

and the rewritten url should be

1.a – http://localhost:8080/mtc/it/main/welcome

1.b – http://www.mydomain.com/it/main/welcome

2) the link in welcome page , which internally is

<h:outputLink value="../../pages/main/welcome.jsf">
<h:outputText value="#{msgs.info}" />
</h:outputLink>

should show the url:

1.a – http://localhost:8080/mtc/it/main/welcome

1.b – http://www.mydomain.com/it/main/welcome

Maybe there is still something missing somewhere, what is wrong?