2

My minimal project compiles and runs fine. However I have a lot of editing to do and new dev work on xhtml pages. I noticed that Eclipse Content Assist doesn't function either on backing bean components or JSF components like primefaces.

Any thoughts on what I'm not thinking of?

I'm attempting to migrate a legacy Dynamic Web Module Maven project from 3.0 to Dynamic Web Module 5.0 using Jakarta Server Faces 4.0.0 in Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components) Version: 2023-06 (4.28.0).

For testing I've created the project (File->New->Dynamic Web Project->) Target Runtime - apache-tomcat-10.0 in TomEE Webprofile 9.1.0 Dynamic web module version - 5.0 Installed JRE - OpenJDK 20.0.1 Jakarta EE 10

The first issue I run into is that Eclipse Content Assist isn't working when editing xhtml files.

Maven Dependencies include.

<dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-api</artifactId>
    <version>10.0.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.myfaces.core</groupId>
    <artifactId>myfaces-api</artifactId>
    <version>4.0.1</version>
</dependency>
<dependency>
    <groupId>org.apache.myfaces.core</groupId>
    <artifactId>myfaces-impl</artifactId>
    <version>4.0.1</version>
</dependency>
<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>12.0.0</version>
    <classifier>jakarta</classifier>
</dependency>
<dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>4.2</version>
</dependency>       

Setting project facets to add Java Server Faces doesn't help. The default max version of JSF is 2.3. Attempting to select (Properties->Project Facets->JavaServer Faces). The expected "Further Configuration Required" appears. I select New User Library and browse to the myfaces-impl-4.0.1 & myfaces-api-4.0.1. The Eclipse dialog box displays "Required class javax.faces.FactoryFinder does not exist in selected libraries."

I know that I can manually edit /Hello-2/.settings/org.eclipse.wst.common.project.facet.core.xml file and add the JSF Facet

<installed facet="jst.jsf" version="4.0"/>

This doesn't help because Eclipse just says that it can't find the implementation of jst.jsf. Screenshot of Eclipse IDE with Project Properties dialogue window open. "Project Facets" menu item is selected, "Java Server Faces" facet list item checkbox is selected. Eclipse IDE Warning is displayed below.

I found some guidance here BalusC Code

Thank you

Ted Spradley
  • 3,414
  • 3
  • 22
  • 26

3 Answers3

1

Changing the facet="jst.jsf" version in Eclipse settings file org.eclipse.wst.commons.project.facet.core.xml from "4.0" to "2.3" allows content assist to work for most library components on xhtml pages. However references to backing bean values such as

<p:outputLabel value="File: #{myBean.myFieldName}" />

won't auto populate. I'm guessing that Eclipse just hasn't caught up with the Jakarata name change? Seems like it would have by now. I could be completely wrong.

org.eclipse.wst.commons.project.facet.core.xml contents:

<faceted-project>
  <runtime name="TomEE-Plus-9.1 (Tomcat v10.0)"/>
  <fixed facet="jst.web"/>
  <fixed facet="java"/>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="java" version="19"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="jst.jsf" version="4.0"/>
  <installed facet="jst.web" version="5.0"/>
  <installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>
<faceted-project>
  <runtime name="TomEE-Plus-9.1 (Tomcat v10.0)"/>
  <fixed facet="jst.web"/>
  <fixed facet="java"/>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="java" version="19"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="jst.jsf" version="2.3"/>
  <installed facet="jst.web" version="5.0"/>
  <installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>
Ted Spradley
  • 3,414
  • 3
  • 22
  • 26
0

Recently, I had the very same issues with my own components and with Omnifaces'.
Nevertheless, code completion worked for PrimeFaces and JSF standard components.

I have a maven WAR project that uses PrimeFaces and Omnifaces artifacts, and uses also another artifact developed by me, in the same eclipse workspace, which contains components.

As you can see, it is not working for my own components (neither Omnifaces): code completion not working

Why is it working for PrimeFaces components? One difference is in the facelet-taglib declaration.
So I copied it. old tag library declaration

But using the old declaration is not enough...
You have to maven-install the library artifact and close the related project in eclipse to make it work with your own components (Omnifaces still not working).
You can see the closed projects on the bottom left, compare with first screen: double context-param declaration

It is not acceptable to trade code completion with ease-of-use and hot code replacement, I want my artifact open. Eventually, there's a workaround.

  1. copy the taglib.xml files in the WAR/WEB-INF folder (also Omnifaces)
  2. change the declaration in the copy to reference faces-2.0 (old style java.sun.com ns)
  3. edit your web.xml and add the old style context-param javax.faces.FACELETS_LIBRARIES (I used both old and new): double context-param declaration

Now, it is working for my components while the lib project is open: enter image description here

And also for Omnifaces components: enter image description here

For completeness of information, my web.xml declaration is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
    version="6.0">

faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="4.0" xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_4_0.xsd">

and my org.eclipse.wst.common.project.facet.core.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <installed facet="java" version="17"/>
  <installed facet="jst.jsf" version="2.3"/>
  <installed facet="jst.web" version="6.0"/>
</faceted-project>
Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73
0

I Found a solution.

  1. Go to project properties
  2. Find "Projet Facets" (typing "fac" in the search box)
  3. In the right panel click the check box "JavaServerFaces" (2.3)
  4. with JavaServerFaces Selected in the right right panel select Runtimes
  5. Select the server where you are going to deploy
  6. Apply and close

Thats it

Eclipse Proyect Properties

  • Yes, I should have added that you can use the GUI to edit the org.eclipse.wst.commons.project.facet.core.xml file which is what you have done. – Ted Spradley Jul 17 '23 at 13:59