The pain of upgrading from JSF 1.2 to 2.0 is based on the view technology you currently use and the future. It depends on the viewing technology you plan to use.
Regardless of switching view technology, you should at least perform the following steps:
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0">
Note: If you are using JSF 2.2 or later, use http://xmlns.jcp instead of http://java.sun.com throughout the XML snippet above. Use the .org namespace domain.
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" >
Note: If you are using Servlet 3.0 or higher, use http://xmlns.jcp instead of http://java.sun.com throughout the XML snippet above. Use the .org namespace domain.
If you are using JSP 2. Basically you don't need to change anything else. Gradual Upgrade
If you are already using a suffix URL pattern (such as , FacesServlet first scans for .xhtml files and if they don't exist, *.jsp It's a good idea to remember to scan your files. This allows for gradual conversion from JSP to Facelets without changing URLs. However, if you are using a prefix URL pattern (e.g. /faces/) and want to upgrade from JSP to Facelets in stages, change it to .jsf and possibly replace the existing All links in the JSP page must also be changed. Please note that the new JSF 2.0 provided implicit navigation does not scan for the existence of the file and navigates to outcome.xhtml anyway. So if you move from .jsp or to .jsp, you still need to include it in the view ID in the JSF 1.x way. I am using Facelets 1.x as my view technology and Facelets 2.0<🎜 comes with JSF 2.0. > If you want to use it, you need to take the following additional steps: JSP 2.x as our view technology and will soon upgrade to Facelets 2.0 If you want to, you'll have to make a lot of changes before publishing your site. We're basically changing the view technique here. If your existing JSP pages are well designed, there will be no scriptlet lines of code and the only JSP-specific tag will be Change as follows. Basic JSP include page template... ... must be changed to the following basic Facelets include page template. The above is the detailed content of What are the challenges of migrating from JSF 1.2 to JSF 2.0, and how do these challenges vary depending on the view technology used?. For more information, please follow other related articles on the PHP Chinese website!Facelets 1.x to Facelets 2.0
Remove the Facelets 1.x JAR from /WEB-INF/lib. Facelets 1.x Remove FaceletViewHandler from faces-config.xml. If you have a custom FaceletViewHandler implementation, you must update it to extend ViewHandlerWrapper. Although unnecessary, for cleanup purposes, remove Facelets 1.x-related
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
Include page changes
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html>
<f:view>
<html lang="en">
<head>
<title>JSP page</title>
</head>
<body>
<h:outputText value="JSF components here." />
</body>
</html>
</f:view>