gpt4 book ai didi

java - SEAM FacesMessage 未显示

转载 作者:行者123 更新时间:2023-11-30 11:42:23 24 4
gpt4 key购买 nike

我正在尝试向现有大型 SEAM 项目的用户添加信息消息。我添加了 <h:messages/>到 .xhtml 页面,这些是我在名为 AbstractChartController 的类的代码中的尝试但是当页面在操作后刷新时,没有显示 FacesMessages,有人知道我接下来可以尝试什么吗?

if (axis.getAxisType() == AxisType.LOGARITHMIC  && axis.getLowestValue() <= 0d){
//Non of this code works:
//Attempt 1
FacesMessages facesMessages = FacesMessages.instance();
facesMessages.add(FacesMessage.SEVERITY_INFO, "Note: Data contains values below or equal to zero so cannot be plotted on a logarithmic axis.");
//Attempt 2
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("Test2");
context.addMessage(null, message);
//Attempt 3
org.jboss.seam.faces.FacesContext myContext = (org.jboss.seam.faces.FacesContext) Component.getInstance("FacesContext");
if (myContext != null) { //Why is this null in debug?
myContext.getContext().addMessage("Test3", message);
}
//Attempt 4:
//StatusMessages.instance()
//.add(StatusMessage.Severity.INFO, "Test4");
// (Compile time error above that it can't find StatusMessages class to import)
System.out.println("FacesMessage added");
...

编辑:“已添加面孔消息”显示在我的 eclipse 控制台中,因此正在运行代码

我在想这个类出于某种原因无法访问 FacesContext?我走在正确的轨道上吗?

最佳答案

StatusMessages statusMessages =  Component.getInstance("statusMessages");
statusMessages.add(Severity.ERROR,"Note: Data contains values below or equal to zero so cannot be plotted on a logarithmic axis.");

关于java - SEAM FacesMessage 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11738325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com