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

查看:148
本文介绍了动态地创建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部件和对话框,显示数据表条目的详细信息。这是非常简单的,当我有一个对话框。我要的是尽量让用户打开两个或三个dailogs不同的条目在同一时间的详细信息。是否有人有任何想法,如何让整个对话与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页面对话框。然后在支持豆我有一些code是这样的:

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天全站免登陆