So, you're on the cutting edge, writing JSF 2.0 applications, but you just get tired of jkl; editing in vi... You can still do JSF 2.0 applications using your IDE, but the price is that you won't have some of the on the fly error checking (especially in your Facelets page).
First, a little about the status of various support efforts - unfortunately, tools support will lag for JSF 2.0, just as it has in other major releases.
I've checked on three different IDEs -
- IntelliJ IntelliJ looks to be doing some
- on JSF 2.0 support, which is unfortunately not publicly available yet - it'll be in Maia, the codename for their next release. You can use the current rev of IntelliJ with JSF 2.0, but you'll get a death of a thousand red squiggles. The good news is that although Maia's release date isn't announced, it appears likely that some sort of early access will be available by JavaOne - but I don't know anything secret, I'm just reading their forums and blogs, so take that prediction for what it is - a guess. I'll blog more once they've made a public release.
- NetBeans NetBeans 6.7 won't have EE 6 support, unfortunately, but they do seem to be integrating what had been an unsupported Facelets plugin into their main line of code - Facelets support is available in their update center as a download. However, this is for Facelets support as a JSF 1.2 addon - it gives an error if you try to use it with JSF 2.0. So, it seems like we'll have to wait for NetBeans.next to really have good JSF 2.0 support - but you can use it now, since NetBeans relies on the libraries bundled in your app server for compilation - you just won't have the GUI sugar that you might want when developing your Facelets XHTML page. See below.
- Eclipse Facelets support was dropped from the Galileo release of Eclipse - it was bumped until the next release, which should happen at around the same time that the rest of Eclipse gets EE 6 support. This puts Eclipse at about the same place as NetBeans, leaving you with something that you can use to edit and compile, but missing code completion and any meaningful debugging support.
I'll run through using both Eclipse and NetBeans with JSF 2.0, but first, a word about what you'll get when you're done - you'll have a nice GUI editor that handles the JSF 2.0 Java classes just fine, but will treat the XHTML as simple XHTML, without knowing any of the Facelets content. So, it'll tell you if you've mismatched a tag, but if you misspell, for instance, h:commandButton as h:commandbuttn, it's up to the server to tell you that when you view the page. Better support will be forthcoming, as I mentioned above, but for now you'll have to be patient.
Also, I'm hardly an expert at either platform, so for those of you who are, comments and suggestions are always welcome.
Instructions for Using Eclipse with JSF 2.0
First, go download a version of Eclipsethat bundles GlassFish, or some other server that supports JSF 2.0.
From that page:
The product distributions contain Eclipse IDE 3.4.1 Java EE IDE, preconfigured GlassFish Server v2.1 and GlassFish Server v3 Prelude and optionally a J2SE 6 1.6.0_12. The Mac OS installer is not available with JDK.
Install and launch it.
Alternatively, you can use your existing Eclipse 3.4 Ganymede installation and get the GlassFish plugin for Eclipse. Read these instructionsto find out how.
To create the project:
File ... New ... Dynamic Web Project
Opens a Wizard.
Project Name: JSF 2.0 Test
Target Runtime: push "New" button, choose Glassfish V3 PROMOTED
Make sure that the "Create a new local Server" box is checked, and click "Next" (these instructions assume you'll be installing a new version of GlassFish. If you already have a version with JSF 2.0, you should be able to figure out which parts are different easily enough.)
Choose your VM (on my Mac, it was the default 1.6)
Enter the name of an empty directory where you want to install the promoted build of GlassFish v3. Click "Install Server". Accept the license at the pop-up, and click "Finish". The server will then install.
The next page, you should be able to just accept all the defaults. Click "Finish". You've now configured your Target Runtime to be something that supports JSF 2.0.
Since the rest of the values that you need are all the defaults, you can go ahead and click "Finish" again". In particular, you don't need to select the "JSF" runtime configuration - since you won't really be using the faces-config.xml file, anyway - since for most uses, it isn't necessary for JSF 2.0.
Your Project is now set up.
You should know what to do next - create a JSF 2.0 app. You can delete the index.jsp page, and fill in with a bunch of xhtml files... The Eclipse IDE knows about the new JSF 2.0 APIs, since by default it uses the API jars bundled into the server. Here's an exampleof a project file structure that I did that worked, just so you can see what files you'll have to change.
Instructions for Using Netbeans with JSF 2.0
You'll need to download the latest NetBeans Nightly Build(no, Beta won't do, since that has a few showstopper bugs for our use).
You'll also need the latest release of GlassFish v3 nightly. (Remember, you're cutting edge, right?) If you're just going after JSF 2.0, though, you could always just use GlassFish v3 Prelude updated to the latest Mojarra release, as described in the release notes.
If you're using GlassFish v3, then you'll need to add the plugin to make that work.
Once all that's done, it's easy - just create a standard JSF project, using the v3 server that you downloaded, just like any other JSF project that you create. You'll need to delete the faces-config.xml file, and change the web.xml file a bit, but like in Eclipse, the server acts as the repository for the requisite APIs. I've attached a sample file to the blog so you can see an example to work from.