Reputation: 1197
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>
Upvotes: 5
Views: 2267
Reputation: 3191
First, you can't mix JSF navigation rules with PrettyFaces Mappings. You have to use one or the other.
<rich:panel style="width:50%;margin-top:100px;" header="Page Not Found.">
<h:link value="Login page" outcome="login" />
</rich:panel>
I believe that "login" should instead be "/login", otherwise JSF may not resolve it. I could be wrong.
<rich:panel style="width:50%;margin-top:100px;" header="Page Not Found.">
<h:link value="Login page" outcome="/login" />
</rich:panel>
Upvotes: 0
Reputation: 31649
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.
Upvotes: 6