不要重新显示< p:messages中对话框中已显示的消息autoUpdate =" true"> [英] Don't redisplay messages already shown in dialog in <p:messages autoUpdate="true">

查看:203
本文介绍了不要重新显示< p:messages中对话框中已显示的消息autoUpdate =" true">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在对话框显示时,我需要显示错误和警告消息。如果没有显示对话框,我需要在容器页面中显示消息

I need to show error and warning messages in a dialog when it is showing. If dialog is not showing I need to show the messages in the container page

我已经在所有视图中使用面孔设置了一个模板: template = /WEB-INF/templates/template.xhtml\">
与此内容:

I have set a template using facelets in all views: template="/WEB-INF/templates/template.xhtml"> with this content:

<f:view locale="#{loginBB.localeCode}">
    <p:messages autoUpdate="true" closable="true" id="globalMessages" />
    <ui:insert name="content" />
</f:view>

在所有对话框中,我有以下内容:

In all dialogs I have the following:

<p:messages autoUpdate="true" closable="true" id="dialogMessages" />

当一个对话框显示错误消息出现在对话框和保存它的视图中,但我需要这只会出现在对话框中。

When a dialog is showing the error messages appear in the dialog and in the view that hold it, but I need that only appears in the dialog.

我做错了什么?我不知道该怎么做

What I am doing wrong? I don't know what to do

编辑:根据BalusC答案,我做了以下:

模板:

<f:view locale="#{loginBB.localeCode}">
    <ui:insert name="dialogs" />
    <p:messages autoUpdate="true" closable="true" redisplay="false" />
    <ui:insert name="content" />
</f:view>

查看:

<ui:define name="content">
    ...
</ui:define>

<ui:define name="dialogs">
    <h:form id="formX">
        <p:dialog ... >
        </p:dialog>
    </h:form>
</ui:define>

打开该对话框时,会在对话框中显示该消息。还行吧。但是当对话框关闭时,它不会在主页上显示消息

When the dialog is opened it show the message in the dialog. This is OK. But when the dialog is closed, it doesn't show the message in the main page

推荐答案

code>< p:messages> 组件有一个 autoUpdate =true。如果只有页面的< p:messages> 自动更新,这将是可行的。如果您可以确保该页面的< p:messages> 出现在JSF组件树之后对话框的

:消息> ,那么这是设置页面< p:messages> 重新显示属性的问题c $ c>到 false ,并确保每个对话框的操作更新对话框自己的表单,其中< p:messages>

That gets tricky if the both <p:messages> components have an autoUpdate="true". It would be doable if only the page's <p:messages> is auto-updated. If you can ensure that the page's <p:messages> appears in JSF component tree after the dialog's <p:messages>, then it's a matter of setting the redisplay attribute of page's <p:messages> to false and making sure that each of the dialog's actions updates the dialog's own form with therein the <p:messages>.

<p:dialog>
    <h:form>
        <p:messages />
        ...
        <p:commandButton ... update="@form" />
    </h:form>
</p:dialog>
<p:messages autoUpdate="true" redisplay="false" />

不需要额外的JS。您可能只需要更改您的模板,以便在< ui:define name =dialogs> 页面的< p:messages> ,以便所有的对话框都在那里。或者,也可以使用CSS来定位页面的< p:messages> 。或者,也许使用JS将页面的< p:messages> 重新定位到您想要在HTML DOM中的页面。

No additional JS is necessary. You may only need to alter your templates to have an <ui:define name="dialogs"> above the page's <p:messages> so that all your dialogs end up there. Or, alternatively, use CSS to position the page's <p:messages> absolutely. Or, maybe, use JS to relocate the page's <p:messages> to there where you'd like to have it in HTML DOM.

这篇关于不要重新显示&lt; p:messages中对话框中已显示的消息autoUpdate =&quot; true&quot;&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆