2016-06-26 8 views
0

ユーザーが自分の個人ページのデータを更新するときに、パスワード要求の確認ダイアログを呼び出して、変更を確認します。ここでパスワードを確認して変更を保存する方法

は私の確認ボタンです:私は、「送信」ボタンを押すと

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

今すぐダイアログが表示されますが、私のメソッドを呼び出しません。

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

そしてここでは、対応する方法であり、 。

+0

フォームの周りにフォームがありますか? –

+0

確かに、私はそれのまわりに形を持っています。 – DimaSan

答えて

1

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

あなたが例に

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

を披露。この意志を参照してください。参照ダイアログボックスを使用してより良いユーザーから値を取得したい場合は、使用からyesまたはno]ダイアログボックスがテイクのために使用されている準拠助けます。ダイアログボックスの使用は簡単です。

+0

ありがとう、私はJavaScriptで2番目の例を試してみます。 – DimaSan

+0

@DimaSan、有用であればansを受け入れてください。 –

+0

ええ、あなたの提案は本当に役に立ちました。 – DimaSan

関連する問題