【发布时间】:2014-02-27 03:12:23
【问题描述】:
我对 p:dialog 有疑问。我将它用作我的 JSF 2.2 应用程序的一部分:
<p:dialog id="cpaDialog" width="300px" widgetVar="changePasswordAdmin" header="#{msg['account.password.change']}" draggable="false" resizable="false">
<h:form id="changePasswordAdminForm">
<h:commandButton immediate="true" value="#{msg['cancel']}" onclick="PF('changePasswordAdmin').hide();"/>
<p:commandButton id="submitCpa" update="changePasswordAdminForm" value="#{msg['submit']}" action="#{accountEditBean.changeAdminPassword()}" oncomplete="if (args && !args.validationFailed) changePasswordAdmin.hide()"/>
<!-- THERE ARE REQUIRED FIELD -->
</h:form>
</p:dialog>
目前我正在使用p:commandButton 提交我的表单并在验证成功通过时关闭对话框。问题是我想在那里使用h:commandButton。你可能会问为什么。案例很简单。我需要这个按钮看起来像一个标准的 h:commandButton 而不应用任何 Primefaces 样式类。
您可能会告诉我:“从 primefaces 按钮中删除所有样式类”。我知道这是可能的(但不是那么有效)如果可能的话,我更愿意在这里使用h:commandButton。
我试过了:
<h:commandButton id="submitCpa" value="#{msg['submit']}" action="#{accountEditBean.changeAdminPassword()}" >
<f:ajax onevent="if (args && !args.validationFailed) changePasswordAdmin.hide()"/>
</h:commandButton>
我使用这个非primefaces按钮的问题是每次按下它都会关闭对话框,而不取决于验证是否成功。
有谁知道在这种特殊情况下如何使用h:commandButton?
【问题讨论】:
标签: jsf jsf-2 primefaces dialog