Jsf CommandButton在我关闭confirmDialog时不调用actionListener
我有停止和释放按钮,它们调用一个保存方法,在保存方法中显示一个确认对话框。我可以使用“停止”按钮,在对话框中按“确定”按钮,该方法就会工作,但当我再次进入“时钟释放”时,该按钮不会调用actionListener。类似于单击释放,确认然后尝试停止 下面是两个命令按钮,它们位于MODE控件内Jsf CommandButton在我关闭confirmDialog时不调用actionListener,jsf,primefaces,dialog,actionlistener,Jsf,Primefaces,Dialog,Actionlistener,我有停止和释放按钮,它们调用一个保存方法,在保存方法中显示一个确认对话框。我可以使用“停止”按钮,在对话框中按“确定”按钮,该方法就会工作,但当我再次进入“时钟释放”时,该按钮不会调用actionListener。类似于单击释放,确认然后尝试停止 下面是两个命令按钮,它们位于MODE控件内 <p:commandButton title="Stop" value="Stop" rendered="#{unitSetVehicleStatusBean.crudMode == '
<p:commandButton title="Stop" value="Stop"
rendered="#{unitSetVehicleStatusBean.crudMode == 'READ' and unitSetVehicleStatusBean.stopped =='false'}"
actionListener="#{unitSetVehicleStatusBean.stop}"
update="modeControls :mainForm"
process="@this :mainForm"/>
<p:commandButton title="Release" value="Release"
rendered="#{unitSetVehicleStatusBean.crudMode == 'READ' and unitSetVehicleStatusBean.stopped =='true'}"
actionListener="#{unitSetVehicleStatusBean.release}"
update="modeControls :mainForm"
process="@this :mainForm"/>
当用户在confirmDialog中选择OK时,它将通过switch语句部分地重新加入该方法并完成保存
这是确认对话框
<p:confirmDialog id="saveNDTDialog" appendTo="@(body)"
widgetVar="saveNDTDialog" closeOnEscape="true"
closable="true"
message="#{message.stoppedValidationNDTWarning}">
<p:commandButton value="OK"
update="mainForm :modeControls"
actionListener="#{unitSetVehicleStatusBean.save('WARNING_NDT')}"
oncomplete="saveNDTDlg.hide();"/>
<p:commandButton value="Cancel"
onclick="saveNDTDlg.hide();" />
</p:confirmDialog>
我相信这个问题与appendTo或者onComplete有关,但是我不太确定到底出了什么问题
欢迎任何建议。通过将对话框从主窗体中拉出,并在对话框中的命令按钮周围添加一个窗体,对话框开始按预期工作。仅用于添加。如果我删除confirmDialog的调用并直接运行save方法,停止和释放按钮就可以很好地工作。除非您使用的是旧的方法,否则我会像您在java方法中所做的那样。此外,我认为“saveNDTDlg”是错误的,除非你有几个对话框。是的,我在PF4上。有几个对话框,我只是举了其中一个的例子,以便于理解。不过我现在已经开始工作了,我会在回答中解释。PrimeFaces论坛上有不止一篇关于这一点的帖子。我很好奇你是否在那里搜索过,你用了什么术语。只是想看看我是否可以尝试在那里用一些评论“标记”帖子,以便将来可以找到它们。顺便说一句,PrimeFaces文档中也提到了这一点。是的,我搜索并尝试过一次,但没有成功。我相信它不起作用是因为oncomplete=“saveHDTDlg.hide()”我将其更改为omcomplete=“PF('saveNDTDialog').hide();”
<p:confirmDialog id="saveNDTDialog" appendTo="@(body)"
widgetVar="saveNDTDialog" closeOnEscape="true"
closable="true"
message="#{message.stoppedValidationNDTWarning}">
<p:commandButton value="OK"
update="mainForm :modeControls"
actionListener="#{unitSetVehicleStatusBean.save('WARNING_NDT')}"
oncomplete="saveNDTDlg.hide();"/>
<p:commandButton value="Cancel"
onclick="saveNDTDlg.hide();" />
</p:confirmDialog>