我有一个对话框,如果我按ESC
键,我想要显示对话框确认(你确定吗?)此事件将触发p:commandButton
。代码如下:
<p:dialog id="dlgEdit" closeOnEscape="false" closable="false" modal="true">
...
...
...
<p:commandButton process="@this" value="SAVE" widgetVar="btnSaveDialogEdit">
<p:confirm ...
message="do you want save?"/>
</p:commandButton>
<p:commandButton process="@this" value="CLOSE" widgetVar="btnCloseDialogEdit">
<p:confirm ...
message="do you want close?"/>
</p:commandButton>
<p:confirmDialog>
...two commandbutton Yes/No
<p:confirmDialog>
<p:hotkey bind="esc" handler="PF('btnCloseDialogEdit').getJQ().click()" />
</p:dialog>
当我点击按钮SAVE
时,只要按do you want save?
键第二个对话框ESC
,就会显示对话框do you want close
。在confirmdialog中,启用closeOnEscape = "true"
。我想,当我在对话框ESC
上按键do you want save?
时,此对话框将被隐藏,但我不能。!!
答案 0 :(得分:0)
您可以通过以下结构实现这一目标:
<p:dialog id="dlgEdit" widgetVar="dlgEdit"
closeOnEscape="true" closable="false" modal="true">
...
...
...
<p:confirmDialog message="Do you want to save?" widgetVar="confirmClose">
<p:commandButton value="Yes"
oncomplete="PF('confirmClose').hide();PF('dlgEdit').hide();" />
<p:commandButton value="No" type="button"
onclick="PF('confirmClose').hide();PF('dlgEdit').hide();" />
</p:confirmDialog>
<p:hotkey bind="esc" handler="PF('confirmClose').show();" />
</p:dialog>
请务必为listener
按钮添加Yes
以处理保存机制。