Search code examples
jsf-2prettyfaces

Prettyfaces weird behaviour when path contains two levels


I am getting a very weird behavior from Prettyfaces 3.3.3 with JSF 2.1.7.
In fact, when I make this mapping:

<url-mapping id="admin-home">
    <pattern value="/adminpage" />
    <view-id value="pages/admin/page.jsf" />
</url-mapping>

Everything works as expected, and when I call pretty:admin-home the redirect is done and I get the right page.
Now when I use this mapping:

<url-mapping id="admin-home">
    <pattern value="/admin/home" />
    <view-id value="pages/admin/page.jsf" />
</url-mapping>

Notice admin and home are separated. I get 404 not found error when calling pretty:admin-home. And it's showing me that the page that was not found is:

admin/pages/admin/page.jsp

Solution

  • I think this is caused by the fact that your viewId is not starting with a / character. My guess is that When PrettyFaces forwards the request to the viewId, the forward is sent relative to the requested URL. This would explain the 404 error.

    So try using this instead:

    <url-mapping id="admin-home">
        <pattern value="/admin/home" />
        <view-id value="/pages/admin/page.jsf" />
    </url-mapping>