英文:
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.
<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.
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 值的引用,例如
<p:outputLabel value="File: #{myBean.myFieldName}" />
不会自动填充。我猜测 Eclipse 可能还没有跟上 Jakarata 的名称更改?看起来现在应该已经跟上了。我可能完全错误。
org.eclipse.wst.commons.project.facet.core.xml 内容:
<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>
<!-- 更改为 "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
<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>
<!-- 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),它不起作用:
为什么PrimeFaces组件起作用?其中一个区别在于facelet-taglib的声明。
所以我复制了它。
但是使用旧的声明还不够...您必须maven-install库构件并关闭eclipse中的相关项目才能使其与您自己的组件一起工作(Omnifaces仍然无法工作)。
您可以在左下角看到已关闭的项目,与第一个屏幕进行比较:
用易用性和热代码替换来交换代码完成是不可接受的,我想要我的构件保持开放。
最终,有一个解决方法。
- 复制WAR/WEB-INF文件夹中的taglib.xml文件(也包括Omnifaces)
- 更改复制中的声明以引用faces-2.0(旧样式java.sun.com ns)
- 编辑您的web.xml并添加旧样式的context-param javax.faces.FACELETS_LIBRARIES(我同时使用了旧样式和新样式):
为了提供完整的信息,我的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):
Why is it working for PrimeFaces components? One difference is in the facelet-taglib declaration.<br>
So I copied it.
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:
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.
- copy the taglib.xml files in the WAR/WEB-INF folder (also Omnifaces)
- change the declaration in the copy to reference faces-2.0 (old style java.sun.com ns)
- edit your web.xml and add the old style context-param javax.faces.FACELETS_LIBRARIES (I used both old and new):
Now, it is working for my components while the lib project is open:
And also for Omnifaces components:
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>
答案3
得分: 0
我找到了解决方案。
- 进入项目属性
- 找到 "项目 Facets"(在搜索框中键入 "fac")
- 在右侧面板中选中复选框 "JavaServerFaces"(2.3)
- 在右侧面板中选择 JavaServerFaces 后选择运行时
- 选择要部署到的服务器
- 应用并关闭
就是这样。
英文:
I Found a solution.
- Go to project properties
- Find "Projet Facets" (typing "fac" in the search box)
- In the right panel click the check box "JavaServerFaces" (2.3)
- with JavaServerFaces Selected in the right right panel select Runtimes
- Select the server where you are going to deploy
- Apply and close
Thats it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论