Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrettyFaces and h:link outcome tag don't redirect to a clean URL

My rewriting with PrettyFaces for an error page doesn't work for a h:link and I don't understand why.

My link should redirect to login.xhtml and it should be /Login.

What is happening, do I miss something?

My rewrite rules navigation :

<navigation-rule>
    <from-view-id>/pageNotFound.xhtml</from-view-id> 
    <navigation-case>
        <from-outcome>login</from-outcome>
        <to-view-id>/login.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

My web.xml for error page handling and Pretty Filter configuration:

<error-page>
    <error-code>404</error-code>
    <location>/pageNotFound.xhtml</location>
</error-page>
<filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>

My pretty-config.xml:

    <url-mapping id="login">
    <pattern value="/Login" />
    <view-id value="/login.xhtml" />
</url-mapping>

My pageNotFound.xhtml:

<rich:panel style="width:50%;margin-top:100px;" header="Page Not Found.">
    <h:link value="Login page" outcome="login" />
</rich:panel>
like image 704
ZheFrench Avatar asked Oct 08 '13 12:10

ZheFrench


1 Answers

Basically, you're mixing Prettyfaces' view id with JSF's one. You can't directly use this id in JSF context, you need to tell it that it's a pretty id. This should work:

<h:link value="Login page" outcome="pretty:login" />

Also if you prefer to use JSF id, you could use /login directly instead:

<h:link value="Login page" outcome="/login" />

Prettyfaces' filter should take into account that it's a mapped id and redirect to your /Login url directly.

like image 167
Xtreme Biker Avatar answered Oct 26 '22 23:10

Xtreme Biker