【问题标题】:Where FacesMessage FacesContext in Thorntail 2.3?Thorntail 2.3 中的 FacesMessage FacesContext 在哪里?
【发布时间】:2019-02-05 05:01:39
【问题描述】:

我正在开发测试任务,堆栈:thorntail 2.3.0.Final,PrimeFaces 6.2。

有例子:

public void onRowEdit(RowEditEvent event) {
    FacesMessage msg = new FacesMessage("Car Edited", ((Car) event.getObject()).getId());
    FacesContext.getCurrentInstance().addMessage(null, msg);
}

但我无法导入 FacesMessageFacesContext,我的 IDE 在所有依赖项中都找不到它们

我的 pom.xml 带 bom 的一点点:

…
    <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>cdi</artifactId>
    </dependency>
    <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>jsf</artifactId>
    </dependency>
…

那么,发生了什么?是 jsf 2.3,对这个包有一些新的方法还是别的什么?

我已经阅读了有关 jsf 2.3 的信息,它具有新功能和一些弃用功能。

还有@ViewScoped?现在我们应该在 CDI 中使用什么?

import javax.faces.* 的包在哪里?

我很困惑……

【问题讨论】:

    标签: jsf jakarta-ee thorntail


    【解决方案1】:

    看起来像 https://github.com/thorntail/thorntail/blob/master/fractions/javaee/jsf/pom.xml 没有将 JSF API 添加为您的应用程序可用的依赖项的错误。

    一个简单的解决方法是在您的项目中将 JSF API 添加为“已提供”,因为它们在运行时可以正常使用。

    【讨论】:

    • @Ken 添加了范围,但运气不好。堆栈跟踪错误。我还创建了一个issue,目前无法将答案标记为已解决
    • Ken 是对的,这是一个错误。我提交了issues.jboss.org/browse/THORN-2327,因为 GitHub 问题不用于 Thorntail v2,仅用于 v4。至于解决方法,您使用了什么坐标?我做了一个小实验,添加org.jboss.spec.javax.faces:jboss-jsf-api_2.3_spec:2.3.5.SP1&lt;scope&gt;provided&lt;/scope&gt; 确实有帮助。
    • @Ken @Ladicek 抱歉,我的错,在 pom io.thorntail:jsf不知何故我插入了&lt;scope&gt;provided&lt;/scope&gt;,所以之后任何实现 jsf 实现的额外依赖项都没有开始。所以答案是正确的!只是添加一些实现,没关系,我添加了javax.faces:javax.faces-api:2.3并且它开始很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-03
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 2012-07-25
    相关资源
    最近更新 更多