How to make Eclipse IDE supports JSF 2.0

In Eclipse Ganymede (v3.4) or Galileo (v3.5), it supports until JSF 1.2 only. For JSF 2.0, upgrade your Eclipse to version Helios (v3.6) onward, it has full support of Java EE 6 support, including JSF 2.0.

Here’s a quick guide to show you how to enable JSF 2.0 features like code assist and visual JSF component editor in Eclipse IDE.

Tools Used

  1. Eclipse 3.6
  2. JSF 2.0.x

1. Eclipse Project Facets

To support JSF 2.0, you need to configure Eclipse project to support Web Tools Platform (WTP).

Steps to enable the Web Tools Platform (WTP) :

  1. Right click on the project, choose “properties” –> “Project Facets“.
  2. Check “Dynamic Web Module“, select version 2.5.
  3. Check “Java“, choose version 1.6.
  4. Check “JavaServer Faces“, choose version 2.0.
    eclipse-jsf-support
  5. Click on the “further configuration…” link below to do the JSF configuration.
  6. Create an user library and include the JSF 2.0 API and implementation libraries, jsf-api-xxx.jar and jsf-impl-xxx.jar.
    P.S You can get the JSF jars official JSF website.

    eclipse-jsf-support
    Updated on 8 Aug 2012
    For JSF 2.1.11, only one jar file javax.faces-2.1.11 is required.
  7. Done.

2. Demo

Now, Eclipse IDE is supporting the JSF 2.0 capabilities. Try it, in .xhtml file, click on the “Ctrl + Space“, it will prompts all available JSF 2.0 tags (code assist) automatically.

Furthermore, it add JSF 2.0 visual components to the web page editor as well, see figure below :

eclipse-jsf-support
Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: water ionizer pay plan loans()

  • Pingback: alkaline water brands()

  • Pingback: parking()

  • Pingback: YouTube favorites kopen()

  • Pingback: water ionizer()

  • Pingback: water ionizer machine()

  • Pingback: laan penge nu 18 aar()

  • Pingback: youporn()

  • Pingback: parking()

  • Pingback: Click Here()

  • Pingback: here()

  • Pingback: streaming movies()

  • Pingback: watch tv show episodes()

  • Pingback: Blue Coaster33()

  • Abraão Isvi

    This is very useful!

  • abhishek

    Hi,
    i am using eclipse 4.2.2 and simple deploying your sample project as you provided the simple step but after properties -project facets-add the user libs and add jar but facing run time problem it is utilized http://localhost:8080/JavaServerFaces but not the defined path with are in web.xml like
    http://localhost:8080/JavaServerFaces/hello.jsf
    http://localhost:8080/JavaServerFaces/hello.faces
    http://localhost:8080/JavaServerFaces/hello.xhtml
    http://localhost:8080/JavaServerFaces/faces/hello.jsf
    what i have to do to resolve this issue.

  • http://[email protected] Ryan Holmes

    I for the life of me can not figure out how to get the faces-config editor to come up. I have downloaded and installed the JSF 2.0, 2.2 libraries, Mojarra, and Apache libraries. I have went into my project properties and made sure the JavaServer Faces 2.0 version was clicked. NO Editor! What is going on?
    I am trying to work my way through a tutorial and this is where I am stuck because in the tutorials it says that a faces-config editor is supposed to pop up where I can select New Managed Bean wizard. There is no “new managed bean wizard” in eclipse as far as I can see. Has anyone else had this problem, all the solutions say to make sure that JavaServer FAces is clicked well it is, and still nothing. Any help would be appreciated.

    Eclipse Java EE IDE for Web Developers.

    Version: Kepler Release
    Build id: 20130614-0229

  • Crazy Dev

    Hi,

    Thanks a lot for the helpful page. I am new to JSF and had done all the eclipse setup with the online help. I made my JSF project setup with the help of above article. The project is setup now and it is also showing me tag assistance on press of Ctrl + Space of jsf tags, but when I run the project, it doesn’t seems to render jsf tags like & and doesn’t show them on the webpage. Using firebug I saw that the tag remains so and is not converted to which is done in case of . Do I need to setup anything else also or any settings change ?

    Please help as I need a project for my work. Thanks in advance.

  • Mandar

    I have been trying to follow the instructions that you mentioned.
    There is an error which says “Failed while installing Dynamic Web Module”

    Reason:Resource exists with a different case in /”ProjectName”/webcontent

    Now.This project is not a dynamic web project.so does it have to anything to do with this?
    And because JSF is dependent on Dynamic Web Module 2.5 or later I am unable to add JSF as well.

  • Pingback: xxxxxxx | Java Snippets()

  • Pingback: JSF 2.0 Tutorial()

  • Pingback: Making Eclipse IDE Supports JSF 2.0 « Akdora’s Blog()

  • http://akdora.wordpress.com akdora

    It helped me. Thanks

  • kalaiselvan

    Hi mkyong….

    I have used eclipse helios… but wen am try to jsf 2.0 project by using the configurations like web module 3.0, Apache tomcat 7.0,configurations jsf v2.0 project and during the jsf capabilities wen i try to choose JSF 2.0 (Mojarra 2.0.3-FCS) for library it displays an error msg “error in opening zip file”…. wat i need to do for tat… whr s the problem… pls reply me asap… its urgent for me…

  • masood

    please send me jsf 2.0 document am new to jsf

  • Pingback: PrimeFaces code completion in Eclipse IDE()

  • benmouh

    Hello MKYONG,

    Think you very much for this Tutorial, then i want to learn from you something in J2EE, if you can give me your Email adresse or contact me in my email adresse thinks lot.

  • http://www.dileeponline.webs.com Dileep

    Hi mkyong,
    How to get the bean assistance in xhtml page if i use multiple faces-config xml files.
    please help me.

  • http://josesaid.com jose said

    hey man, why aer you using eclipse helios and not using Galileo?

  • Vikas

    Which technology you prefer as best..?Struts2 or JSF2

  • Pingback: Delicious Bookmarks for April 26th through April 27th « Lâmôlabs()

  • A B

    I have a question regarding mixing jsp for JSF 1.2 and xhtml for JSF 2.0 in a JSF 2.0 project.

    We are using websphere. Is it possible to convert a project to use JSF 2.0 facets, but keep the original jsps that use IBM’s JWL and create new pages as JSF 2.0 xhtml pages and have both run within the same application within the same webapp?

    Thanks

    • http://www.mkyong.com mkyong

      WebSphere.. Good Luck bro, i have too many bad experienced on it. Each WebSphere version have different implementation and NOT compatible to each other, make sure you consult the IBM documentation.

      To be frankly, WebSphere is a IBM standard, not Java standard, what apply on standard Java App Server may fail on WebSphere. Often times, you need to “hack” something to get what you want.

  • nour

    Hi ,mkyong

    I have followed the steps which you mentioned to configure eclipse Helios v3.6 and the tutorials work well but the JSF visual editor does not appear at all , so what to do to show the visual editor .

    thank you .

  • Femi

    Hi Mkyong, what about Eclipse Galileo, How can I make support JSF 2.0 jar?

    • http://www.mkyong.com mkyong

      Is above solution not working in your Galileo?

  • ram

    Most of the code are uncomplete : need to know how-to-update-row-in-jsf-datatable ?
    Advanced thanks

  • Gang

    Never mind. I got it work. I had to uncheck the Dynamic Web Moudle and apply, change the version and re-check it.

    Gang

  • Gang

    Hi, mkyong,

    I followed your steps to configure my eclipse-helio for JSF 2.0. But the IDE displays error, “Cannot change version of project facet Dynamic Web Module to 2.5″. It was originally “2.3” and JavaServer Faces 2.0 requires 2.5. Any idea?

    I created a Maven project using apache’s webapp architype.

    Thanks,
    Gang

    • David Dhune

      Gang,

      Try this below may work:

      In your project workspace, in settings folder
      edit org.eclipse.wst.common.project.facet.core (xml file)

      add <installed facet="jst.web" version="”/>

      • David Dhune

        Add the version you want.

  • Klaus

    Hi,
    thanks for this very helpfull tutorial.
    I have just one question regarding jsf 2.0 and css :
    How to invoke an external stylesheet e.g. “layout.css” in my jsf 2.0 project.

    I tried this :

    Eclipse Helios says unknown Tag <h:outputStylesheet…

    Do you have any idea \ suggestion how to fix this ?
    Thanks in advance and best regards
    Klaus

  • Geno

    I guessed that the problem was with it being able to edit .xml configs. It seems that doing this on an existing project causes problems, but doing this with a brand new project is okay.

    Must be an Eclipse bug…

    • http://www.mkyong.com mkyong

      What’s your Eclipse version?

  • Geno

    Hi
    When I enable the JSF facet, doing it exactly as described in your post, I get the following error:

    Failed while installing JavaServer Faces 2.0

    Reason:
    ‘myproject’ : unable to configure web module for JavaServer Faces

    • David Dhune

      Geno,

      Try this below may work, In your project workspace, in settings folder edit org.eclipse.wst.common.project.facet.core (xml file)

      add

      • David Dhune
      • David Dhune

        add another line with facet jst.jsf and version as 2.0

        • Franzo

          It works, thanks David, and thx Mkyong!

    • hioxy

      Netbeans is good at JSF2 develop.