Wednesday 15 June 2011

jsf 2 - Redirect 404 error with Prettyfaces 3.3.X and JSF 2.2 -



jsf 2 - Redirect 404 error with Prettyfaces 3.3.X and JSF 2.2 -

i want redirect 404 errors custom url prettyfaces. seek lot of thing can't find right solution case (despite lot of post this)

here informations

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jsf configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.facelets_skip_comments</param-name> <param-value>true</param-value> </context-param> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - prettyfaces configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <context-param> <param-name>com.ocpsoft.pretty.development</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.ocpsoft.pretty.base_packages</param-name> <param-value>com.lagoon.project.web</param-value> </context-param> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - server configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>/</welcome-file> </welcome-file-list> <error-page> <exception-type>404</exception-type> <location>/page-introuvable</location> </error-page> </web-app>

under web pages\modules\website

<?xml version="1.0" encoding="utf-8"?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>todo supply title</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <div>404</div> </body> </html>

the bean

import com.ocpsoft.pretty.faces.annotation.urlmapping; import javax.enterprise.context.requestscoped; import javax.faces.bean.managedbean; @requestscoped @urlmapping(id = "pagewebsitepagenotfound", pattern = "/page-introuvable", viewid = "/modules/website/pagenotfound.xhtml") @managedbean(name = "pagewebsitepagenotfound") public class pagewebsitepagenotfound { }

and pom file

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.lagoon</groupid> <artifactid>project</artifactid> <version>0.1.0-snapshot</version> <packaging>war</packaging> <name>project</name> <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <java.version>1.7</java.version> <jsf.version>2.2.8-02</jsf.version> <spring.version>4.1.1.release</spring.version> </properties> <dependencies> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - web - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <dependency> <groupid>com.sun.faces</groupid> <artifactid>jsf-api</artifactid> <version>${jsf.version}</version> </dependency> <dependency> <groupid>com.sun.faces</groupid> <artifactid>jsf-impl</artifactid> <version>${jsf.version}</version> </dependency> <dependency> <groupid>com.ocpsoft</groupid> <artifactid>prettyfaces-jsf2</artifactid> <version>3.3.3</version> </dependency> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - misc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <dependency> <groupid>javax</groupid> <artifactid>javaee-web-api</artifactid> <version>7.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <compilerarguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerarguments> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.3</version> <configuration> <failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputdirectory>${endorsed.dir}</outputdirectory> <silent>true</silent> <artifactitems> <artifactitem> <groupid>javax</groupid> <artifactid>javaee-endorsed-api</artifactid> <version>7.0</version> <type>jar</type> </artifactitem> </artifactitems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>

when seek "/page-introuvable" jsf show me page... if seek "/somethingelse" have standard 404 error navigator

how can ?

thanks

in web.xml set block of cody

<error-page> <error-code>404</error-code> <location>/404page.xhtml</location> </error-page>

it intercept 404 error , redirect page page, define page @ <location>/404page.xhtml</location>.

jsf jsf-2 jsf-2.2 prettyfaces

No comments:

Post a Comment