按照这里的例子,我试图覆盖Primefaces上下文菜单的show()方法。
这是我的代码:
<p:tree value="#{myTreeBean.mainTreeRoot}" id="myTree>
<p:ajax event="contextMenu" listener="#{myTreeBean.onRightClickSelectListener}" oncomplete="PF('serverTreeMenuVar').show()"/>
[...]
</p:tree>
<p:contextMenu widgetVar="myTreeMenuVar" for="myTree" id="myTreeMenu" model="#{myBean.contextMenuModel}"></p:contextMenu>
<script>
$( function() {
PF('myTreeMenuVar').show = function(e) {
console.log('my function');
// call the generic implementation:
PrimeFaces.widget.ContextMenu.prototype.show.call(this,e);
}
});
</script>
不幸的是,我得到了错误:
未捕获类型错误:无法读取未定义的属性“pageX”
我用的是PF 7.0
覆盖正常,问题是由以下行引起的:
<p:ajax event="contextMenu" listener="#{myTreeBean.onRightClickSelectListener}" oncomplete="PF('serverTreeMenuVar').show()"/>
特别是来自
oncomplete="PF('serverTreeMenuVar').show()"