primefaces close dialog on init don't work

风格不统一 提交于 2020-01-07 08:07:31

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/25780435/primefaces-close-dialog-on-init-dont-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!