XHTML, Facelets, and NetBeans IDE
By johnc on May 31, 2006
I was trying to do the Facelets tutorial in NetBeans IDE, and the tutorial calls for lots of XHTML files. Unfortunately, NetBeans makes it very hard to create XHTML pages with the .xhtml suffix.
First I had to actually find the XHTML template. It's not under Web, which is strange because HTML is there. After searching (OK, Geertjan told me), I found it in the Other category. Problem solved, right? Wrong.
The XHTML File Wizard doesn't let you specify the extension and automatically gives an XHTML file an .html extension, although it correctly recognizes it as an XML file and not a regular HTML file.
So the only way to really do this is to register the .xhtml extension as belonging to XML files. Choose Tools > Options > Advanced Options > IDE Configuration > System > Object Types > XML Objects and add .xhtml to the Extension and MIME Types category. (Side note - this setting really needs to get promoted to the main Options panel. It's one I use quite a bit and it's terribly buried in the Advanced Options. Actually, I'd rather be able to right-click any unrecognized file and choose Treat As... to register the extension with an object type.)
Now that the extension's registered, use the Other > Empty File template. This is the only template that will allow you to specify an extension. Give the file the .xhtml extension and it'll show up correctly as a file, although not with any of the skeleton code. It'll just be an empty file. Better than nothing, though.
BTW - if you're trying to do facelets in NetBeans IDE, it's not really easy. There's no code completion in the XHTML files, since schema-based code completion hasn't been implemented yet. If you use jspx files, it's supposed to work, but last I looked at it code completion wasn't working there either. Check out Mark Overdij's blog for a quick run-through of getting it going.