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

huangapple go评论85阅读模式
英文:

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

问题

我的最小项目编译和运行正常。但是我有很多编辑工作要做,并且需要在xhtml页面上进行新的开发工作。我注意到Eclipse Content Assist在后台bean组件或JSF组件(如primefaces)上也无法正常工作。

对于我没有考虑到的事情有什么想法吗?

我正在尝试将遗留的Dynamic Web Module Maven项目从3.0迁移到Dynamic Web Module 5.0,使用Eclipse IDE for Enterprise Java and Web Developers(包括Incubating components)版本为2023-06(4.28.0),使用Jakarta Server Faces 4.0.0。

为了测试,我已创建了该项目(文件->新建->Dynamic Web Project->)
目标运行时 - apache-tomcat-10.0 in TomEE Webprofile 9.1.0
动态Web模块版本 - 5.0
已安装的JRE - OpenJDK 20.0.1
Jakarta EE 10

我遇到的第一个问题是,编辑xhtml文件时,Eclipse Content Assist无法工作。

Maven依赖项包括。

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

设置项目facets以添加Java Server Faces并没有帮助。JSF的默认最大版本是2.3。尝试选择(属性->项目facets->JavaServer Faces)。会出现“需要进一步配置”的提示。我选择新用户库并浏览到myfaces-impl-4.0.1和myfaces-api-4.0.1。Eclipse对话框显示“所选库中不存在所需类javax.faces.FactoryFinder”。

我知道我可以手动编辑/Hello-2/.settings/org.eclipse.wst.common.project.facet.core.xml文件并添加JSF Facet

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

这并没有帮助,因为Eclipse只是说它找不到jst.jsf的实现。

我在这里找到了一些指导意见 BalusC Code

谢谢。

英文:

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.

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

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

&lt;installed facet=&quot;jst.jsf&quot; version=&quot;4.0&quot;/&gt;

This doesn't help because Eclipse just says that it can't find the implementation of jst.jsf.
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

I found some guidance here BalusC Code

Thank you

答案1

得分: 1

将 Eclipse 设置文件 org.eclipse.wst.commons.project.facet.core.xml 中的 "jst.jsf" 版本从 "4.0" 更改为 "2.3" 可以使大多数 xhtml 页面上的库组件的内容辅助功能正常工作。但是,对于后备 bean 值的引用,例如

&lt;p:outputLabel value=&quot;File: #{myBean.myFieldName}&quot; /&gt;

不会自动填充。我猜测 Eclipse 可能还没有跟上 Jakarata 的名称更改?看起来现在应该已经跟上了。我可能完全错误。

org.eclipse.wst.commons.project.facet.core.xml 内容:

&lt;faceted-project&gt;
  &lt;runtime name=&quot;TomEE-Plus-9.1 (Tomcat v10.0)&quot;/&gt;
  &lt;fixed facet=&quot;jst.web&quot;/&gt;
  &lt;fixed facet=&quot;java&quot;/&gt;
  &lt;fixed facet=&quot;wst.jsdt.web&quot;/&gt;
  &lt;installed facet=&quot;java&quot; version=&quot;19&quot;/&gt;
  &lt;installed facet=&quot;wst.jsdt.web&quot; version=&quot;1.0&quot;/&gt;
  &lt;installed facet=&quot;jst.jsf&quot; version=&quot;4.0&quot;/&gt;
  &lt;installed facet=&quot;jst.web&quot; version=&quot;5.0&quot;/&gt;
  &lt;installed facet=&quot;jst.jaxrs&quot; version=&quot;2.0&quot;/&gt;
&lt;/faceted-project&gt;

<!-- 更改为 "2.3" -->
<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>

英文:

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

&lt;p:outputLabel value=&quot;File: #{myBean.myFieldName}&quot; /&gt;

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:

&lt;faceted-project&gt;
  &lt;runtime name=&quot;TomEE-Plus-9.1 (Tomcat v10.0)&quot;/&gt;
  &lt;fixed facet=&quot;jst.web&quot;/&gt;
  &lt;fixed facet=&quot;java&quot;/&gt;
  &lt;fixed facet=&quot;wst.jsdt.web&quot;/&gt;
  &lt;installed facet=&quot;java&quot; version=&quot;19&quot;/&gt;
  &lt;installed facet=&quot;wst.jsdt.web&quot; version=&quot;1.0&quot;/&gt;
  &lt;installed facet=&quot;jst.jsf&quot; version=&quot;4.0&quot;/&gt;
  &lt;installed facet=&quot;jst.web&quot; version=&quot;5.0&quot;/&gt;
  &lt;installed facet=&quot;jst.jaxrs&quot; version=&quot;2.0&quot;/&gt;
&lt;/faceted-project&gt;

<!-- Change to "2.3" -->
<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>

答案2

得分: 0

以下是您要翻译的内容:

最近,我遇到了与我的组件以及Omnifaces相同的问题。
尽管如此,PrimeFaces和JSF标准组件的代码完成功能正常工作。

我有一个使用PrimeFaces和Omnifaces构件的maven WAR项目,还在同一个eclipse工作区中使用了我开发的另一个构件,其中包含组件。

正如您所看到的,对于我的组件(以及Omnifaces),它不起作用:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

为什么PrimeFaces组件起作用?其中一个区别在于facelet-taglib的声明。
所以我复制了它。
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

但是使用旧的声明还不够...您必须maven-install库构件并关闭eclipse中的相关项目才能使其与您自己的组件一起工作(Omnifaces仍然无法工作)。
您可以在左下角看到已关闭的项目,与第一个屏幕进行比较:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

用易用性和热代码替换来交换代码完成是不可接受的,我想要我的构件保持开放。
最终,有一个解决方法。

  1. 复制WAR/WEB-INF文件夹中的taglib.xml文件(也包括Omnifaces)
  2. 更改复制中的声明以引用faces-2.0(旧样式java.sun.com ns)
  3. 编辑您的web.xml并添加旧样式的context-param javax.faces.FACELETS_LIBRARIES(我同时使用了旧样式和新样式):
    Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

现在,在我的构件打开的情况下,它适用于我的组件:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

也适用于Omnifaces组件:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

为了提供完整的信息,我的web.xml声明如下:

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

以及我的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>
英文:

Recently, I had the very same issues with my own components and with Omnifaces'.<br>
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):
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

Why is it working for PrimeFaces components? One difference is in the facelet-taglib declaration.<br>
So I copied it.
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

But using the old declaration is not enough...<br>
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).<br>
You can see the closed projects on the bottom left, compare with first screen:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

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):
    Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

Now, it is working for my components while the lib project is open:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

And also for Omnifaces components:
Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

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

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

faces-config.xml:

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

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

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;faceted-project&gt;
  &lt;installed facet=&quot;java&quot; version=&quot;17&quot;/&gt;
  &lt;installed facet=&quot;jst.jsf&quot; version=&quot;2.3&quot;/&gt;
  &lt;installed facet=&quot;jst.web&quot; version=&quot;6.0&quot;/&gt;
&lt;/faceted-project&gt;

答案3

得分: 0

我找到了解决方案。

  1. 进入项目属性
  2. 找到 "项目 Facets"(在搜索框中键入 "fac")
  3. 在右侧面板中选中复选框 "JavaServerFaces"(2.3)
  4. 在右侧面板中选择 JavaServerFaces 后选择运行时
  5. 选择要部署到的服务器
  6. 应用并关闭

就是这样。

Eclipse 2023 Content Assist for xhtml files with Jakarta Server Faces 4.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 2023 Content Assist for xhtml files with Jakarta Server Faces 4.0.

huangapple
  • 本文由 发表于 2023年7月3日 06:36:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76601035.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定