开发者

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

开发者 https://www.devze.com 2022-12-18 06:07 出处:网络
How to activate eclipse (3.5, WTP) content assist in .xhtml pages for JSF (1.2) tags, using facelets?

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 changin开发者_如何学Cg 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)


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.


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:

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


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


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:

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

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.


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.


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.


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


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!


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


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

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消