如何通过确认密码保存更改



当用户在他的个人页面上更新数据时,我想调用一个带有密码请求的确认对话框来确认更改。

这是我的确认按钮:

<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;
}

现在当我按下"提交"按钮时,对话框出现了,但没有调用我的方法

http://www.primefaces.org/showcase/ui/overlay/confirmDialog.xhtml

符合性对话框用于从用户处获取是或否,如果你想从用户处获取值,最好使用符合性对话框,请参见示例展示

http://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml

这对你有帮助。对话框的使用很简单

相关内容

  • 没有找到相关文章

最新更新