« Maven Projects and... | Main | Eclipse Helios -... »

Eclipse Helios - JSF Content Assist for xhtml files

After I upgrade my Eclipse IDE form Galileo (3.5) to Helios (3.6) I wondered that the Content Assist for xhtml files is not working. This was a problem with all early versions of eclipse (See my blog for Eclipse Galileo).

The Problem in Helios is that the support of content assist for xhtml files was not in the feature list again and is still not supported out of the box. There are various discussions about this topic.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=192393

 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=314098

https://bugs.eclipse.org/bugs/show_bug.cgi?id=315892

How to get things work...

After all there is a way to configure a maven based JEE web project to get the content assist for xhtml files. The following discription assumes that your are working with Glassfish 3.1 or Glassfish 2.1 (this is the instance where we fetch the JSF-Impl Library for Eclipse)

Support for .xhtml Files in Eclipse IDE

First you need to add the xhtml file type to the general configuration of your Eclipse Workspace. Eclipse Helios did not know hat .xhtml is a general file type for web developers.

Open the preferences "Window>>Preferences" and choose the section "General->Content Types"

 

 Here you cann add the File extension "*.xhtml" to the JSP Node.

Next got to the Section "General -> Editors -> File Assouciations" and choose your new file extension .xhtml

 

You need to make shour that the JSP Editor is the default Editor for this file type. (you can click the "Default" button)

Now Eclipse will now that a XHTML File is something like a jsp file.

But to get the content assist work correctly we need to configure now the web project.

Configure your web project

Open the Preferences dialog for your Web Project and choose the section "Project Facets". For a Maven Project you will typical see the link "Convet to faceted form...." when you open this dialog the first time. When you click the link you well be able to add different project faccets.

First you need to add the "Dynamic Web module 2.5",

 


You will see a link "further configuration available". Click on this link
You can add the maven web folder : src/main/webapp


I recommand to disable the option "Generate web.xml" to avoid that eclipse manipulates your existing web.xml file.

Next add the Facete  "JavaSeverFaces 1.2". The Version number is in both cases important!

 


And again click on "further configuration available". A new dialog will open where you now need to configure a jsf User Library. Click on the button "manage libraries"




and create a new jsf libray - for example named "jsf-lib"



Now that you have added a new User Libary you need to add the JSF impl Jar to this libray. You can take this jar from your glassfish Installation.
In Glassfih 3.1 you find this file in

GLASSFISH_INSTALL/glassfish/moduls/jsf-api.jar

For Glassfish 2.1 this is the library

/GLASSFISH_INSTALL/lib/javaee.jar

 

After all you can now add this user Libray to your java SeverFaces Configuration.

Now when you are open an .xhtml file with the jsp editor you will hopefully have the content assist working