动态创建 PrimeFaces 对话框 [英] Create PrimeFaces dialogs dynamically

查看:29
本文介绍了动态创建 PrimeFaces 对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 primefaces 3.3.1 和 JSF 2 (Mojarra 2.1.9).

I'm using primefaces 3.3.1 and JSF 2 (Mojarra 2.1.9).

我有一个带有 DataTable 组件和 Dialog 的页面,用于显示 DataTable 条目的详细信息.当我有一个对话框时,这非常简单.我想要的是尝试允许用户同时打开两个或三个包含不同条目详细信息的 dailog.有人知道如何从服务器获取与 AJAX 的整个对话,而不仅仅是对话内容吗?

I have a page with a DataTable component and Dialog to show details of DataTable entries. That's very simple when I have one dialog. What I want is to try to allow users to open two or three dailogs with details of different entries in the same time. Does somebody have any idea how to get whole dialog with AJAX from server, not just a dialog content?

推荐答案

是的,我做到了.为此,我在支持 bean 中以编程方式创建了必要的对话框.我知道这不是真正的最佳实践,但此刻我认为这只是可能的解决方案.首先,我添加了一个组面板,它是我的 JSF 页面上的对话框的容器.然后在支持 bean 上我有一些这样的代码:

Yes I did. For this purpose I created necessary dialogs programmatically in backing bean. I know this is not really best practice, but in this moment I think this is only possible solution. First of all I added one group panel which is container for dialogs on my JSF page. Then on backing bean I have some code like this:

UIComponent panelGroup = facesContext.getViewRoot().findComponent("panel_id");
Dialog dialog = new Dialog();
dialog.setHeader("Sample");
dialog.setVisible(true);
dialog.setMinimizable(true);
...
panelGroup.getChildren().add(dialog);
...
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.update("panel_id");

这篇关于动态创建 PrimeFaces 对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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