使用PrimeFaces通过< p:dialog>启动对话框.和< ui:include> [英] Launching dialogs using PrimeFaces via <p:dialog> and <ui:include>

查看:142
本文介绍了使用PrimeFaces通过< p:dialog>启动对话框.和< ui:include>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将PrimeFaces UI库用于我的Web UI项目.

I am using PrimeFaces UI library for my web UI project.

我有一个manage_watchfolder.xhtml页面,该页面带有一个按钮,此按钮将启动一个对话框:

I have a manage_watchfolder.xhtml page that has a button, and this button launches a dialog:

<p:commandButton value="Add" oncomplete="dlgEditWF.show()"
    update=":editWFForm" process="@none"/>  

在同一文件中,我包含了edit_watchfolder.xhtml中的dlgEditWF:

Inside this same file I have dlgEditWF included from edit_watchfolder.xhtml:

<p:dialog id="editDialog" widgetVar="dlgEditWF" modal="true"
    resizable="true" onShow="showHideActionLocation();">
    <ui:include src="edit/edit_watchfolder.xhtml"/>
</p:dialog> 

问题是我不希望在单击按钮之前加载.但是,edit_watchfolder.xhtml在创建manage_watchfolder.xhtml的同时被加载".因此,所有从edit_watchfolder.xhtml调用的bean都会被创建,初始化等,即使用户也可能永远不会真正单击该按钮.这会产生大量开销,并使执行速度变慢.

The problem is that I do not want edit_watchfolder.xhtml to be loaded before the button is clicked. However, edit_watchfolder.xhtml is "loaded" at the same moment manage_watchfolder.xhtml is created. So, all the beans called from edit_watchfolder.xhtml are created, initialized, etc, even user maybe will never actually click on the button. This creates a lot of overhead, and makes execution slow.

我可以避免吗?

推荐答案

您可以使用p:dialog的动态"属性.看看文档.

You can use the "dynamic" attribute of p:dialog. Have a look at the primefaces documentation.

<p:commandButton id="basic" value="Show Dialog" onclick="dlg.show();" type="button" />  

<p:dialog id="dialog" header="Dynamic Dialog" widgetVar="dlg" dynamic="true">  
    <h:outputText value="This content is loaded lazy." />  
</p:dialog>  

这篇关于使用PrimeFaces通过&lt; p:dialog&gt;启动对话框.和&lt; ui:include&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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