初始化的initfaces关闭对话框不起作用 [英] primefaces close dialog on init don't work

查看:263
本文介绍了初始化的initfaces关闭对话框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Primefaces 5.0和我试图使用PF Dialog Framework功能,但有一些问题。
我使用openDialog()方法打开一个对话框。
在对话框bean中,我管理了一个使用@PostConstruct注释的init()方法。
在该方法中,我读取参数并加载记录列表(与dataTable绑定)。
所有似乎工作正常...对话框打开,我选择一个记录,关闭closeReturn等等。



但是我想要在init()如果找到单个记录,我可以立即关闭对话框。
所以我调用closeDialog(),传递我的bean ...但没有什么发生...对话框打开,我必须手动关闭它。
这是令人沮丧的...



有人可以帮助我吗?



谢谢

解决方案

您可以使用primefaces requestContext从您的bean中关闭对话框。

  @PostConstruct 
public void init(){
recordList = loadListOfRecords();
if(recordList.size()== 1){
RequestContext.getCurrentInstance()。execute('yourDialogWidgeVar.close()');
}
}

这只是一个关闭Bean对话框的可能性。我不知道是否符合你的要求。
请稍后再发贴。很难找出你的问题。


Im'using Primefaces 5.0 and I tried to use PF Dialog Framework features, but with some problems. I open a dialog using openDialog() method. In the dialog bean I managed an init() method annotated with @PostConstruct. In that method I read parameters and load a list of records (to bind with a dataTable). All seems work fine... dialog opens, I choose a record , close with closeReturn and so on.

But I want that in init(), if a single record was found, I could close immediately the dialog. So I call closeDialog(), passing my bean... but nothing happens... the dialog opens and I have to close it manually. And this is frustrating...

Could anyone help me?

Thanks

解决方案

You can use primefaces requestContext to close the dialog from your bean.

@PostConstruct
public void init() {
    recordList = loadListOfRecords();
    if ( recordList.size() == 1 ) {
        RequestContext.getCurrentInstance().execute('yourDialogWidgeVar.close()');
    }
}

This is just a possibility to close a dialog from Bean. I don't know if it fits to your demands. Please post your code next time. It is hard to figure out your problem without it.

这篇关于初始化的initfaces关闭对话框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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