< p:dialog>的渲染属性和可见属性之间的差异. [英] Difference between rendered and visible attributes of <p:dialog>

查看:282
本文介绍了< p:dialog>的渲染属性和可见属性之间的差异.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用PrimeFaces 3.2.我想知道设置<p:dialog> rendered 属性与设置 visible 有何区别? >属性.什么时候应该使用这些属性中的任何一个?

I am using PrimeFaces 3.2 in my project. I wanted to know what is the difference between setting the rendered attribute of a <p:dialog> as against setting the visible attribute. When should I use either of these attributes?

推荐答案

rendered属性是服务器端,而visible属性是客户端. rendered属性告诉JSF是否应生成对话框的HTML表示形式. visible属性告诉HTML/CSS/JS是否应在浏览器页面加载时立即显示对话框.

The rendered attribute is server-side and the visible attribute is client-side. The rendered attribute tells whether JSF should generate the dialog's HTML representation or not. The visible attribute tells whether HTML/CSS/JS should immediately show the dialog on browser's page load or not.

如果未呈现对话框,则您将无法通过例如JavaScript dialogWidgetVar.show()来显示该对话框,而无需重新加载页面或对对话框的父组件之一进行ajax更新,以使对话框的条件评估为true.此外,如果不仅仅因为不呈现对话框而无法呈现对话框,则visible属性也不会起作用.

If the dialog isn't rendered, then you won't be able to display it by for example JavaScript dialogWidgetVar.show() without reloading the page or ajax-updating one of the dialog's parent components that way so that the dialog's rendered condition evaluates to true. Also the visible attribute won't have any effect if the dialog is not rendered simply because there's nothing being rendered to the resulting HTML output which could be shown/hidden by JavaScript.

如果呈现对话框,则默认情况下它是隐藏的.您可以将visible设置为true以强制其在打开页面时立即显示对话框.或者,您可以在某些onclickoncomplete属性中调用JavaScript dialogWidgetVar.show()来显示它.

If the dialog is rendered, then it is by default hidden. You can set visible to true to force it to display the dialog immediately whenever the page is opened. Or you can invoke JavaScript dialogWidgetVar.show() in some onclick or oncomplete attribute to show it.

如果您根本不想渲染对话框,请使用rendered属性,例如,因为在当前请求的页面组合中无论如何都不会使用该对话框.

Use the rendered attribute if you don't want to render the dialog at all, for example because it wouldn't ever be used anyway in the currently requested page composition.

这篇关于&lt; p:dialog&gt;的渲染属性和可见属性之间的差异.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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