I recently upgraded to Eclipse Helios (3.6), and they now have support for JSF 2.0. In particular, the Web page editor understands and shows previews for the h: facelets tags, and the editor has all sorts of shortcuts when editing the faces-config.xml file.
Let me first summarize what I did, for those who haven't yet tried it in Helios. I'll ask some questions along the way, and if anyone has suggestions on improving the process, I'd appreciate them.
1) Make a new Dynamic Web Project. If you choose Tomcat 6 as the target runtime, you have to choose Custom for the Configuration, click on Modify, then select JavaServer Faces 2.0. If you choose Tomcat 7 as the target runtime, one of the Configuration choices is "JavaServer Faces v2.0 Project". Odd that there would be this discrepancy, since JSF 2.0 has no tie to servlets 3.0 (which is what Tomcat 7 adds over Tomcat 6). If you choose Glassfish 3 as the target runtime, there is also a Configuration option for "JavaServer Faces v2.0 Project". This also strikes me as a tiny bit odd, since I would think projects for Glassfish 3 or other Java EE 6 servers should support JSF 2 automatically. In all these cases, you can also retroactively add in JSF 2 support by right-clicking on the project and going to Properties and Project Facets.
2) The first time you select JSF 2, you click on "Further Configuration" (or "Next") and eventually get to a screen that asks for the JSF Implementation Library. You click on the icon on the right, create a new library name (eg "JSF 2.0") and point at the needed JAR files (jsf-api.jar, jsf-impl.jar, jstl-1.2-api.jar, jstl-1.2-impl.jar). You only have to do this the first time; it remembers the JAR locations for the future.
3) Eclipse then puts the JAR files in WEB-INF/lib and creates a web.xml and a faces-config.xml for you. However, I can't figure out how to customize how these files look. In particular, I don't like the web.xml that it creates, and can't figure out how to change what Eclipse makes for me. For example, even though I choose only *.jsf as the URL-pattern, it puts *.faces in anyhow (in addition to *.jsf). It also puts in a couple of entries I don't want, and does NOT put in Development for PROJECT_STAGE. As a result, I am manually copying in a web.xml to each project that I create, which seems a bit silly. Anyone know how to customize the web.xml that gets created? Or the faces-config file?
4) As far as I can tell, Eclipse does not automatically associate the correct editor with .xhtml files in these new JSF 2 projects. If you just double click on an .xhtml file, it comes up in the normal HTML editor. You have to either R-click on the file and do Open With --> Web Page Editor, or go to Window, Preferences, General, Editors, File Associations, select *.xhtml, and make Web Page Editor the default.
5) The Web page editor does not seem to know about implicit navigation. If you make an h:commandButton with an action of "foo" and also create a file called foo.xhtml, it says "The action value does not match a navigation outcome". No big deal, except that I don't like having files lying around in my projects with the warning icons on them, since doing so gets me in the habit of ignoring warnings. I'd be satisfied if I could just disable this particular warning. It is probably somewhere under Window, Preferences, Web, JavaServer Faces Tools, Validation, but I didn't see it.
Any suggestions on improvement from the Eclipse experts out there would be appreciated!
Cheers-
- Marty
-----
http://www.coreservlets.com/JSF-Tutorial/jsf2/
[Message sent by forum member 'martyhall']
http://forums.java.net/jive/thread.jspa?messageID=482970