Eclipse autocomplete (content assist) with facelets (jsf) and xhtml
Asked Answered
M

10

50

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)

Marquis answered 25/1, 2010 at 22:37 Comment(1)
are there any other answers that worked for this, as neither work for me, with .xhtml and rich faces.Catenate
M
70

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 here.

Another, a bit more complex solution is described here.

Marquis answered 25/1, 2010 at 23:1 Comment(4)
Maybe he was angry, that you answered your own question ;-) By the way, It worked for me as well! (+1)Cluny
This worked me for Galileo but now switched to the latest version Indigo and I cannot get it work. Anyone luck with Eclipse 3.7 Indigo + Facelets?Oblige
For Eclipse 3.7 adding JavaServer Faces 2.0 facet to the project solved the issue for me. *.xhtml is already registered in the Preferences window under HTML.Coloratura
this doesn't work for me, i still cant get code assist on .xhtml files for rich faces.Catenate
S
49

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

Substantialize answered 30/8, 2011 at 11:52 Comment(2)
Bozho's solution didn't work for me at first. But your solution of adding a JSF facet to my project worked immediately. Merci MihailLiberticide
this doesn't work for me, I still cant get code assist on .xhtml file.Catenate
F
7

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

Footlocker answered 26/1, 2010 at 0:31 Comment(5)
good. But is it certainly working with .xhtml extension? Anyway, my preferred solution is the non-additional-plugin oneMarquis
yes it works with xhtml out of the box and a lot more things that are useful if you do JSF development, including any tag library, even custom facelets tags.Footlocker
since I use SpringSource Tool Suite, it feels strange if I install JBoss's and SpringSource's tools in the same installation =)) I sure hope it will work.Unimpeachable
Adding a plugin should be for the plugin's own merits, not to add a functionality that Eclipse has on its own.Substantialize
Didn't work here, and it's really heavy (couldn't use if worked)... :(N
H
2

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.

Hyrcania answered 2/9, 2015 at 18:7 Comment(3)
what do you mean in the place where Remove JSF Capabilities is located?Otorhinolaryngology
@Otorhinolaryngology Perhaps the answer was a bit unclear. In my case I had already added the capabilities, which is why the picture says Remove JSF Capabilities. If I had not done that already, it would say Add JSF Capabilities instead. Thanks for the comment.Hyrcania
thanks. I could not solve the problem even though I had jboss tools :(Otorhinolaryngology
B
1

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.

Brouhaha answered 25/1, 2010 at 23:42 Comment(1)
I haven't considered it for two reasons: 1. it's not free 2. the last time I evaluated it it was so buggy I had to reinstall eclipse in a while. True it was a long time ago, but stil..Marquis
N
1

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.

Nymph answered 18/7, 2014 at 15:53 Comment(0)
C
1

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".

Churchyard answered 10/3, 2015 at 7:34 Comment(0)
E
1

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!

Eades answered 10/6, 2015 at 6:39 Comment(0)
C
1

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

Cerebroside answered 4/1, 2016 at 3:51 Comment(1)
In my eclipse (luna) there is no option for adding JSF Capabilities. Instead in the project properties > Project Facets I have enabled JavaServer Faces at version 2.2. But still no content asist in xhtml fileBedstead
J
0

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).

Jemina answered 23/4, 2013 at 6:7 Comment(2)
Just add JSF project facet.Stuccowork
@Stuccowork err.. it's not a good answer. but i can't find out the project facets selection that @Substantialize suggested.Jemina

© 2022 - 2024 — McMap. All rights reserved.