首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >确定p:growl中消息/growl的严重程度

确定p:growl中消息/growl的严重程度
EN

Stack Overflow用户
提问于 2018-01-24 04:43:53
回答 1查看 390关注 0票数 0

我在我的支持bean中有以下代码:

代码语言:javascript
复制
try {
    contractService.create(selectedContract);
    conversation.end();
    return "search?faces-redirect=true";
} catch (ActiveContractExistsException e) {
    FacesContext context = FacesContext.getCurrentInstance();
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, e.getMessage()));
    return null;
}

在jsf中:

代码语言:javascript
复制
<p:growl id="growl" showDetail="true" showSummary="false" closable="true" autoUpdate="true"/>

代码语言:javascript
复制
<p:commandButton value="Save" actionListener="#{contractView.update}" update="growl"/>

结果,我得到了:

就像你可以看到的,这与SEVERITY_ERROR相去甚远。但最有趣的部分是当我的代码如下时(在catch块之外添加消息):

代码语言:javascript
复制
    try {
        contractService.create(selectedContract);
        conversation.end();
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Some message"));
        return "search?faces-redirect=true";
    } catch (ActiveContractExistsException e) {
        //FacesContext context = FacesContext.getCurrentInstance();
        //context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Some message"/*e.getMessage()*/));
        return null;
    }

然后一切都很好:

如何在处理异常时为我的消息设置SEVERITY_ERROR级别?

EN

回答 1

Stack Overflow用户

发布于 2018-01-25 16:53:11

我的问题与EE容器有关。如果我不是从EJBException扩展过来的,它们会自动包装,因此块catch不会执行。有两种方法可以解决我的问题:

  1. 将我的自定义异常从EJBException
  2. Add @ApplicationException批注扩展到我的类异常
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48410473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档