首页 > 解决方案 > Thorntail 2.3 中的 FacesMessage FacesContext 在哪里?

问题描述

我正在开发测试任务,堆栈: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);
}

但是我无法导入FacesMessage,并且FacesContext我的 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.*

我很困惑……</p>

标签: jsfjakarta-eethorntail

解决方案


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

一个简单的解决方法是在您的项目中将 JSF API 添加为“提供”,因为在运行时它们将被很好地使用。


推荐阅读