Jsf 2 基于bean中的值在PrimeFaces中显示对话框
我有一个Jsf 2 基于bean中的值在PrimeFaces中显示对话框,jsf-2,primefaces,Jsf 2,Primefaces,我有一个p:dialog,它通过命令按钮的oncomplete显示 <p:commandButton value="Update" id="update" actionListener="#{serviceTypeViewBean.beforeUpdate}" oncomplete="updatedlg.show();)"> </p:commandButton> 如何在commandButton的oncomplete中添加此条件?您可以使用EL求值来呈现
p:dialog
,它通过命令按钮的oncomplete
显示
<p:commandButton value="Update" id="update"
actionListener="#{serviceTypeViewBean.beforeUpdate}"
oncomplete="updatedlg.show();)">
</p:commandButton>
如何在commandButton的oncomplete中添加此条件?您可以使用EL求值来呈现/隐藏javascript代码:
oncomplete=#{不是空的serviceTypeViewBean.list?'updatedlg.show()':''}
另请参见:
方法代码添加如下内容:
if(list != empty){
RequestContext.getCurrentInstance().addCallbackParam("emptyList", false);
} else {
RequestContext.getCurrentInstance().addCallbackParam("emptyList", true);
}
然后可以在oncomplete
属性中检查参数,如下所示:
<p:commandButton value="Update" id="update"
actionListener="#{serviceTypeViewBean.beforeUpdate}"
oncomplete="if(!args.emptyList) { PF('updatedlg').show(); }">
</p:commandButton>
请注意callbackParam是灵活的,您可以在许多情况下找到它的用法
<p:commandButton value="Update" id="update"
actionListener="#{serviceTypeViewBean.beforeUpdate}"
oncomplete="if(!args.emptyList) { PF('updatedlg').show(); }">
</p:commandButton>