【问题标题】:Primefaces update component after dialog close event对话框关闭事件后 Primefaces 更新组件
【发布时间】:2016-08-30 23:36:31
【问题描述】:

我使用 Primefaces 对话框框架打开一个对话框

RequestContext.getCurrentInstance().openDialog("myDialog", options, null);

然后,我想在对话框的关闭事件之后更新基本页面中的组件。我知道我们可以添加一个 'dialogReturn' ajax 事件

<p:ajax event="dialogReturn" update = ":form:colors"  />

但是如何使用对话框框架以编程方式执行此操作?

【问题讨论】:

  • 有同样的问题..如何将ajax的东西传递给openDialog()-方法

标签: jsf primefaces dialog ajax-update


【解决方案1】:

解决方法:

将打开对话框的动作分配给按钮;使用 javascript 调用该按钮的 click() 方法并为其分配一个 dialogReturn:

public void openDialogWithJS(){
            RequestContext.getCurrentInstance().execute("$('#myForm\\\\:myButton').click()");
    }



public void showDialog(){
    RequestContext.getCurrentInstance().openDialog("myDialog", options, null);
}
<h:form id="myForm">
                <p:commandButton id="myButton" actionListener="#{myBean.showDialog}" style="display: none;">
                    <p:ajax event="dialogReturn"  update = "myComponentId"/>
                </p:commandButton>
</h:form>

【讨论】:

  • 有个东西叫p:remoteCommand。无需滥用隐藏按钮。
猜你喜欢
  • 1970-01-01
  • 2014-12-04
  • 1970-01-01
  • 2011-10-03
  • 1970-01-01
  • 1970-01-01
  • 2017-06-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多