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

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

问题描述

我必须努力<我已经在setHeaderName()中写入了名称getter和setter.但是我看不到<头的名称. 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...)

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

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.Adam

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

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