Eclipse autocomplete (content assist) with facelets (jsf) and xhtml

JavaEclipseJsfFacelets

Java Problem Overview


How to activate eclipse (3.5, WTP) content assist in .xhtml pages for JSF (1.2) tags, using facelets? It works in .jsp files, but not xhtml.

I google a lot, and in many places (including MyFaces wiki) it is said - "Eclipse can't work with xhtml and facelets"

Since this works with .jsp files, I assume there might be some mechanism with which to activate that content assist.

I started working on a project, which has already a large codebase, so changing the extensions is not an option. Additional plugins are aslo undesirable, but acceptable if nothing else works.

(I'm asking the question to verify if someone hasn't found a witty workaround to this issue - otherwise I know it's not possible)

Java Solutions


Solution 1 - Java

Found the solution pretty quickly after asking the question (and an hour after I started attempting to solve it):

Window > Preferences > General > Content Types > Text > JSP > Add (xhtml)

Makes the files be treated as jsp ones. Thus when they are opened with the JSP editor, the autocomplete of any tag library that has its definitions in .tld format (<h: and <f for example) works. Facelets, and facelets-only tags still don't work. Their .tld equivalents should be added somewhere in the projects. Facelet's tld can be found https://facelets.dev.java.net/files/documents/3448/21641/jsf-ui.tld">here</a>;.

Another, a bit more complex solution is described http://blogger.ziesemer.com/2008/03/facelets-and-xsd-converted-tlds.html">here</a>;.

Solution 2 - Java

In Eclipse Indigo (3.7) adding *.xhtml as a jsp does not work.

Adding a project facet solves the issue:

Right click on the project -> Preferences -> Project Facets -> Click on "JavaServer Faces", version should most probably be 2.0.

Then it asks for a library, you can click on "disable...", because most probably you already would have the jars configured. I don't have mine as a library so I ignored that part.

Screenshot: enter image description here

Solution 3 - Java

Use JBoss Tools, it is what I use for my JSF+Facelets projects. It is the best you can get if you need to work with this technology.

http://www.jboss.org/tools

I recommend using the latest candidate release which is CR1 as it is the one compatible with Eclipse 3.5, the final version should be out soon but CR1 is rock solid.

http://in.relation.to/Bloggers/JBossTools31CR1Released

Solution 4 - Java

I had JBoss Tools installed and had JavaServer Faces facet configured for my project (in Eclipse Mars), but still didn't get any content assist from my .xhtml files. A solution not mentioned here is to choose Add JSF capabilities:

Add JSF Capabilities

Simply right click the project, and select Configure -> Add JSF Capabilities.

It would look like the picture above but it would say Add JSF Capabilities instead of Remove JSF Capabilities. In the above picture, I had already added JSF capabilities.

Solution 5 - Java

Have you thought about MyEclipse? It isn't free, but it is a pretty nice tool. It helped a lot when I developed with JSF.

Solution 6 - Java

Check that you have include primefaces namespace! So your html tag could look like following:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">

I have been using in Eclipse Luna and primefaces 5.

Solution 7 - Java

If nothing work you must go to Preferences->General->Keys Then search for "content assist" if only one "content assist" for "when" "Editing Java source" exist copy this command. And set the binding to ctrl+space and when "Editing JSP Source".

Solution 8 - Java

If you already installed JBoss Tools and still have this problem then uninstall JBoss tools. Restart eclipse. Make sure you don't have any JBoss tool lingering in your installed components list.

Now go back to eclipse market.

Install just: JBoss JSF, JBoss Richfaces and JBoss Visual Page Editor from the JBoss tool set. Do not download the whole package which comes with over 30+ tools. It is a bloated package and will slow down eclipse and unnecessary bloat your eclipse instance.

Enable JSF facet with latest JSF implementation library. I'd recommend you to directly download it this jar from the official JSF website.

Close eclipse.

Open eclipse and create a new workspace.

Import the project back into the new workspace.

This worked for me!

Solution 9 - Java

I have install JBoss Tool for JSF coding purpose.But in *.XHTML it was not showing content assist for ManagedBean..so I did following steps that's work for me.

For my project this steps worked.

1)Right click on project --> Configure-->Add JSF Capabilities.. Step-by-step procedure (Vailaaa!!! Problem Solve).. Go to Xhtml file and try to code #{m^anagedBeans.HelloJSF()} where (^) this is the sysmbol there you just have to "Ctrl+space" Content Assist will work.here

Solution 10 - Java

Suggestion: in eclipse Indigo(classic) and working with maven projects

as the picture you can see bellow, can't find Project Facets selection that @mist suggested (because am haven't installed any plugins but m2e I guess).

enter image description here

so, I did this to solve that issue:

Window >> Preference >> General >> Content Types >> XML >> Add file association (*.xhtml)

this work not so well (content stoppage).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBozhoView Question on Stackoverflow
Solution 1 - JavaBozhoView Answer on Stackoverflow
Solution 2 - JavamistView Answer on Stackoverflow
Solution 3 - JavakpoliceView Answer on Stackoverflow
Solution 4 - JavaMagnilexView Answer on Stackoverflow
Solution 5 - JavaMichael BalintView Answer on Stackoverflow
Solution 6 - JavaShekh AktherView Answer on Stackoverflow
Solution 7 - JavaRyuImperatorView Answer on Stackoverflow
Solution 8 - JavaChaitanyaBhattView Answer on Stackoverflow
Solution 9 - JavaSandesh MoreView Answer on Stackoverflow
Solution 10 - JavaTeifiView Answer on Stackoverflow