设置 <p:dialog> 的标题在动态 [英] Set header of <p:dialog> in dynamically

查看:15
本文介绍了设置 <p:dialog> 的标题在动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为 < 设置 headp : dialog> 在 JSF 中.我已将名称 getter 和 setter 写入 setHeaderName().但我看不到 < 的标题名称.p : 对话框>如何在 PrimeFaces 中动态更改 p:dialog 的头部.

I have to set head for < p : dialog> in JSF.I have written into setHeaderName() for name getter and setter.But I can not see the name of the header of < p : dialog> How to change dynamically head of p:dialog in PrimeFaces.

推荐答案

正如 mareckmareck 之前提到的,您可以通过对组件使用简单的 ajax 更新来实现.

As mentioned by mareckmareck before, you can do so by using a simple ajax update to the component.

此外,我建议使用标题事实而不是标题属性,例如:

Additionally, I would recommend to use the header fact instead the header attribute like:

<p:dialog id="someDialog" widgetVar="someDialog_var">
   <f:facet name="header">
       <h:outputText id="someDialogHeader" value="#{backingBean.dialogHeader}"/>
   </f:facet>
    ...
 </p:dialog>

和匹配

<p:commandButton value="Change dialog header"
actionListener="#{someBackingBean.changeHeader}"
update="someDialogHeader"/>

(顺便复制并扩展了这里提供的 mareckmareck 示例...)

(I copied and extended the example provided mareckmareck here by the way...)

这是一个更好的解决方案,因为现在您可以只更新标题文本,而不是整个对话框.(当然,更新整个 Dialog 也适用于这种方法.)

This is a better solution because now you can update the headers text only, instead of the entire Dialog. (Of cause updating the entire Dialog will work with this approach too.)

此外,您可能已经注意到,一旦您更新了整个对话框,您的对话框就会关闭.这种方法也解决了这个问题.

Also, you may have noticed, that your dialog will close once you update the entire Dialog. This approach gets rid of that problem too.

此致,

J.亚当

这篇关于设置 &lt;p:dialog&gt; 的标题在动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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