当用户更新其个人页面上的数据时,我想调用带有密码请求的确认对话框来确认更改。
这是我的确认按钮:
<p:commandButton value="Confirm" update="message" ajax="false" actionListener="#{customerBean.confirmChanges()}">
<p:confirm header="Confirm changes" icon="ui-icon-alert" message="Please enter your password to confirm changes:"/>
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Submit" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
<p:commandButton value="Cancel" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
<p:password value="#{customerBean.currentPassword}" required="true" redisplay="true" label="Current Password"/>
</p:confirmDialog>
以下是相应的方法:
public String confirmChanges() {
if (currentPassword.equals(customer.getPassword())) {
saveCustomer();
logger.info("\nCustomer updating SUCCESS.", " CustomerID:" + customer.getId());
addMessage("Updating Success", "Your information was successfully updated.", SEVERITY_INFO);
}
addMessage("Updating Error", "Your password is wrong please try again.", SEVERITY_ERROR);
currentPassword = null;
return null;
}
现在,当我按下“提交”按钮时,会出现对话框,但不会调用我的方法。
答案 0 :(得分:1)
http://www.primefaces.org/showcase/ui/overlay/confirmDialog.xhtml
符合对话框用于从使用中获取是或否,如果您想从用户更好地使用值来使用对话框,请参阅参考展示示例
http://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml
这会对你有所帮助。使用对话框很简单。