当我关闭confirmDialog时,CommandButton没有调用actionListener

时间:2015-03-09 17:08:44

标签: jsf primefaces dialog actionlistener

我有按钮Stop和Release调用save方法,在save方法中显示confirmDialog。我可以使用“停止”按钮,在对话框中按“确定”,方法可以正常工作,但是当我再次进入“时钟释放”按钮时,按钮不会调用actionListener。类似于单击Release,确认然后尝试停止。

以下是两个命令按钮,它们位于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"/>

这是confirmDialog。它调用的save方法是从stop()和release()方法中调用的,然后经过一些验证我使用

RequestContext context = RequestContext
                        .getCurrentInstance();
                context.execute("PF('saveNDTDialog').show();");
                break;

当用户在confirmDialog中选择OK时,它将通过switch语句部分重新加入此方法并完成保存。

这是confirmDialog。

<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有关,但不太确定会出现什么问题。

欢迎任何建议......

1 个答案:

答案 0 :(得分:0)

通过从主窗体中拉出对话框并在对话框中的commandButtons周围添加一个表单,对话框开始按预期工作。

相关问题