My blog has moved!

You should automatically be redirected in 6 seconds. If not, visit
and update your bookmarks.

Thursday, 8 May 2008

Using Facelets with NetBeans 6.1 (without nbfaceletssupport)

Update 27. May 2008: You can download the Facelets NetBeans plug-in for 6.1 from:

I'm a fan of Facelets when it comes to templating for JSF applications. Prior to version 6.1 of NetBeans I was using the nbfaceletssupport plug-in. Sure, it had its quirks, but overall it was a good plug-in. After installing NetBeans 6.1 and really got into using all the new cool features (shared libraries being the most significant) I realised that the nbfaceletssupport plug-in for NetBeans 6.0 didn't work and a fix had not yet been released at the nbfaceletssupport project site (note: Po-Ting Wu of Sun Microsystems has provided instructions on how to re-compile the plug-in for NetBeans 6.1). This also happened when I switched from NetBeans 5.5.1 to 6.0, so I anticipate that this will also happen in the future. So, I thought to myself, why not use the powerful XML support already built-in NetBeans to give me what I need. What I really needed the plug-in for is code completion. So, here goes. First I decided to drop JSP pages (.jsp) for JSP documents (.jspx). The difference being that .jspx is pure XML and .jsp is HTML.

Facelets file as a JSP page (.xhtml):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xmlns:ui="" xmlns:h="">
<title>JSP facelets file</title>

<ui:composition template="/resources/templates/page.xhtml">
<ui:define name="pageTitle">This is a page title</ui:define>
<ui:define name="pageContent">This is the page content</ui:define>


Facelets file as a JSP document (.jspx):

<jsp:root version="2.0" xmlns:html="" xmlns:jsp="" xmlns:ui="" xmlns:h="" xmlns:f="" xmlns:fn="" xmlns:t="" xmlns:c="" xmlns:jsfExt="">
<ui:composition template="templates/page.xhtml">
<ui:define name="pageTitle">This is a page title</ui:define>
<ui:define name="pageContent">This is the page content</ui:define>

When creating facelets file as JSP document in NetBeans you will automatically get code completion (without any third-party plug-ins).

For this to work, ensure that the following configuration is set it web.xml:


and that the faclets tag library descriptor (TLD) is accessible in the classpath (eg. /WEB-INF/tlds).



Anonymous said...

This is stupid, We have hundreds of *.xhtml files in our project, i will not be changing their extension now.

Allan Lykke Christensen said...

If you don't want to rename your files I recommend that you follow the instructions for re-building the NetBeans plug-in - a 5 min process.

ifnu said...

this is instruction to build your own facelets support for 6.1

i'v build it and put it in google code

Allan Lykke Christensen said...

Good job ifnu!

Anonymous said...

i've downloaded the zip file for updates and also downloaded the latest NB6.1 installed with web features. im getting the following errors don't know why.
Missing required modules for Plugin Facelets Support:
JSP Parser [module org.netbeans.modules.web.jspparser/3 = 200804211638]

thanks sri

Anonymous said...

i fixed the problem provided here