Change Password Validation
ambrish_kumar May 27, 2009 12:25 PMHi Everyone,
I want to validate the New Password field with Confirm password field.
Here is my code,
<s:decorate id="newPass" template="layout/edit.xhtml"> <ui:define name="label">New Password :</ui:define> <h:inputSecret id="newPassId" size="30" maxlength="100" required="true" requiredMessage="Value is required." value="#{changePassword.newPass}" validator="#{changePassword.validatePassword}" > </h:inputSecret> </s:decorate> <s:decorate id="confirmPass" template="layout/edit.xhtml"> <ui:define name="label">Confirm Password :</ui:define> <h:inputSecret id="confirmPassId" size="30" maxlength="100" required="true" requiredMessage="Value is required." value="#{changePassword.confirmPass}" validator="#{changePassword.validatePassword}"> </h:inputSecret> </s:decorate> <a:commandButton id="changePass" value="Submit" action="#{changePassword.changePass}" style="cursor:hand;cursor:pointer;"> </a:commandButton>
and the validator code is,
public void validatePassword(FacesContext context, UIComponent toValidate, Object value) { String password = (String) value; if(!(password.equals(confirmPass))){ ((UIInput)toValidate).setValid(false); SeamResourceBundle srb = new SeamResourceBundle(); String passwordError = srb.getString("message.verify.user.password"); FacesMessage message = new FacesMessage(passwordError); message.setSeverity(javax.faces.application.FacesMessage.SEVERITY_ERROR); context.addMessage(toValidate.getClientId(context), message); } }
Now the problem is that , when I submitt the form then I am getting null value for confirmPass.
Should i use a:support on both inputSecret text box?
Thanks
Ambrish