【发布时间】:2015-03-09 17:08:44
【问题描述】:
我有调用保存方法的停止和释放按钮,并在保存方法中显示了一个确认对话框。我可以使用“停止”按钮,在对话框中按“确定”并且该方法有效,但是当我再次进入时钟释放时,该按钮不会调用 actionListener。类似点击释放,确认然后尝试停止。
这是两个命令按钮,位于 modeControls 内。
<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"/>
这里是确认对话框。它调用的 save 方法是从 stop() 和 release() 方法中调用的,然后经过一些验证后我使用
RequestContext context = RequestContext
.getCurrentInstance();
context.execute("PF('saveNDTDialog').show();");
break;
当用户在 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 方法,Stop 和 Release 按钮将完美运行。
-
我相信 dialog.hide() 在 PF5(或者是 5.1)中已弃用。除非您使用旧的东西,否则我会像在 java 方法中那样做。另外我认为“saveNDTDlg”是错误的,除非你有几个对话框
-
是的,我在 PF4 上。有几个对话框,我只是举了一个例子,以便于理解。我现在已经开始工作了,会在回答中解释..
标签: jsf primefaces dialog actionlistener