Search code examples
eclipsejsfjakarta-eemyfacesjakarta-migration

Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0


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


Solution

  • 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>