私はJSFで2つのパスワードフィールドを検証しようとしていますが、今まではうまくいきませんでした。Googleで検索しましたが、すべてがJSF 1.2であり、かなり混乱しています。ajaxで2つのパスワードフィールドを検証する方法は?
これは私がこれまでやっているものです:
<h:outputLabel for="password" value="Password:" />
<h:inputSecret id="password" value="#{register.user.password}" >
<f:ajax event="blur" listener="#{register.validatePassword}" render="m_password" />
</h:inputSecret>
<rich:message id="m_password" for="password"/>
<h:outputLabel for="password_2" value="Password (again):" />
<h:inputSecret id="password_2" value="#{register.user.password_2}" >
<f:ajax event="blur" listener="#{register.validatePassword}" />
</h:inputSecret>
これは私それが私のコントローラである方法です:
public void validatePassword() {
FacesMessage message;
if (!user.getPassword().equals(user.getPassword_2())){
message = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "different password");
}else{
message = new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok");
}
FacesContext.getCurrentInstance().addMessage("form:password", message);
}
任意のアイデアの男?
あなたはそれがうまくいかないとはどういう意味ですか?それは遅いですか?あなたが何を変えたいのか、なぜそれを理解しているのか分かりません。 – jdias
こんにちは@jdias、私はそれがあると思われる方法で動作していないことを意味します。おかげさまで、少し混乱するかもしれません。 –