First of all, JSF 2.0 support both JSP and facelets files. In theory you can change your JSF implementation version and keep using your old JSF 1.2 libraries. But it is usual that the same "JSF 2.0 library alternates" does not work as expected, because they could target only facelets as View Declaration Language (VDL). One known example is MyFaces Tomahawk that was written in that way to keep it closer to the spec.
If your are already working with facelets, the necessary changes are minimal, but if you are working with JSP it is a good moment to change to facelets for JSF 2.0. In that way you'll enjoy all cool features like:
- Partial State Saving
- Composite Components
- JSF 2.0 Resource Handling
- JSF 2.0 Ajax
When migrating JSF 1.2 (or even 1.1) applications, keep in mind that JSF 2.1 has some improvements that makes easier convert JSP applications into facelets applications. It is strongly suggested to move directly to JSF 2.1.
Moving from .jsp to facelets .xhtml
Just follow the checklist:
- Rename your files to .xhtml.
- update all your headers.
- replace your jsp:include with ui:import.
- remove your f:verbatim tags.
- update your faces-config.xml navigation rules.
Upgrading .jspx files
You can configure facelets engine to process .jspx files instead JSP, minimizing the necessary changes required for your application. To do that, follow this list:
- Configure facelets engine to handle files in different ways using <facelets-processing> tag inside <faces-config-extensions> entry on faces-config.xml (For more information see JSF 2.1 spec Appendix A 188.8.131.52 The facelets-processing element).
<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_1.xsd" version="2.1"> <faces-config-extension> <facelets-processing> <file-extension>.jspx</file-extension> <process-as>jspx</process-as> </facelets-processing> </faces-config-extension> </faces-config>