【问题标题】:Messages not working inside Primefaces TabView消息在 Primefaces TabView 中不起作用
【发布时间】:2014-05-05 14:32:33
【问题描述】:

我有一个名为“fieldWrapper”的自定义标签,用于将标签与其各自的输入绑定并提供验证消息。

组件代码:

<h:panelGroup id="#{for}CompleteFieldContainer"
              styleClass="completeFieldContainer"
              layout="block"
              rendered="#{rendered}">
    <h:panelGroup id="#{for}FieldWithLabelContainer" layout="block"
                  styleClass="fieldWithLabelContainer #{fieldWrapperBean.getRequiredClass(required)} #{totalSizeClass}">
        <c:if test="#{!empty check and check}">
            <div class="labelContainer #{labelSizeClass} checkInput">
                <ui:insert />
            </div>
            <div class="labelContainer #{for}LabelContainer checkStyle">
                <h:outputLabel for="#{for}" value="#{label}" title="#{title}"/>
            </div>
        </c:if>            
        <c:if test="#{empty check or not check}">
            <div class="labelContainer #{labelSizeClass} #{for}LabelContainer #{checkStyle}">
                <h:outputLabel for="#{for}" value="#{label}" title="#{title}"/>
            </div>
            <ui:insert />
        </c:if>
    </h:panelGroup>
    <h:panelGroup rendered="#{renderError}" layout="block" styleClass="messageContainer">
        <p:message for="#{for}" id="#{for}Message" rendered="true"/>
    </h:panelGroup>
</h:panelGroup>

这个标签的一个例子如下:

<gitags:fieldWrapper for="codeInput"
                     label="#{msg.code}"
                     labelSizeClass="size75"
                     totalSizeClass="size175"
                     required="false">
        <p:inputText id="codeInput" 
                     value="#{clienteFinderManager.codigo}"
                     styleClass="inputText size100"/>
</gitags:fieldWrapper>

它会自动为该输入添加一条消息,该消息在 bean 验证触发时呈现。

它在除 p:tabView 之外的所有组件中都能完美运行。

当我在 tabView 中使用它时,消息已排队但未写入,但是,如果我在写入组件后手动添加消息:

<gitags:fieldWrapper for="codeInput"
                     label="#{msg.code}"
                     labelSizeClass="size75"
                     totalSizeClass="size175"
                     required="false">
        <p:inputText id="codeInput" 
                     value="#{clienteFinderManager.codigo}"
                     styleClass="inputText size100"/>
        <p:message for="codeInput" id="codeInputMessage" rendered="true"/>
</gitags:fieldWrapper>

Bean Validation Inside Tabs

知道为什么会这样吗?

【问题讨论】:

    标签: jsf primefaces bean-validation


    【解决方案1】:

    这是一个错误:https://code.google.com/p/primefaces/issues/detail?id=5238

    在 primefaces 5.0 中修复。

    【讨论】:

      【解决方案2】:

      我在任何 primeface 版本中都有一个修复程序。 您需要使用 而不是 。 取一个字符串变量 message 并将错误消息设置为。将 保留在 中的 tabChange 事件中,从 bean 调用 action 方法并清空错误消息。因为我们每次更改选项卡时都需要清除错误消息。单击提交按钮后,只会显示错误消息。 如果有任何澄清,请联系我。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-17
        • 1970-01-01
        • 1970-01-01
        • 2015-12-20
        • 2019-09-07
        • 2023-04-10
        相关资源
        最近更新 更多