【问题标题】:XSP JSF FacesContext addMessage does not always workXSP JSF FacesContext addMessage 并不总是有效
【发布时间】:2018-02-15 01:53:01
【问题描述】:

我有一个 JSF 页面,用户正在其中输入一些信息。当用户提交数据时,它首先被验证,如果提交成功,用户也应该得到一个 FacesMessage。

我有一个菜单栏的自定义控件,我在每个页面中都使用它:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:panel>
        <xp:this.facets>
             <!-- Some Logos and stuff -->
              <xp:panel xp:key="contentFacet">
                    <xp:callback facetName="contentContainer"></xp:callback>
              </xp:panel>
        </xp:this.facets>
    </xp:panel>
</xp:view>

然后按以下方式使用菜单:

<xc:cc_layout_main><xp:this.facets>
    <xp:panel xp:key="contentContainer">
        <xc:cc_content_form></xc:cc_content_form></xp:panel>
    </xp:this.facets></xc:cc_layout_main>

cc_content_form 使用这个控件:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:messages id="messages1" styleClass="test" layout="table"
        errorClass="alert-warning" fatalClass="alert-danger"
        infoClass="alert-info" warnClass="alert-warning" showDetail="true"
        showSummary="true" disableTheme="false" globalOnly="false">
    </xp:messages>

    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[
// Validierungs Nachrichten entfernen
var delayMs = 750;
$('body')
    .on('click', function(event){
        x$('#{id:messages1}').delay(delayMs).fadeOut(500);
    })
    .on('keyup', function(event){
        x$('#{id:messages1}').delay(delayMs).fadeOut(500);          
    })
]]></xp:this.value>
    </xp:scriptBlock>

</xp:view>

在提交函数中,我在验证函数中使用了这个:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", "some error")); 

这个调用被包装在一个带有单音模式的辅助类方法中,因此它可以在所有页面中使用。对于验证消息,这工作得很好,但在我返回 actionResult "xsp-success" 之前在验证方法中更进一步,它不起作用。没有消息显示,我没有收到任何异常。

有人可以帮忙吗?

【问题讨论】:

    标签: jsf xsp


    【解决方案1】:

    原来我搞砸了 NavigationRules ...它工作得很好

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-26
      • 1970-01-01
      • 1970-01-01
      • 2012-04-23
      • 2015-06-28
      • 2015-12-04
      • 2017-01-08
      相关资源
      最近更新 更多