Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6592273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:32:01+00:00 2026-05-25T17:32:01+00:00

I was having some problem with password validation, which @BalusC help me out, here

  • 0

I was having some problem with password validation, which @BalusC help me out, here.
But after I insert the validation code in my form, when I call the controller method, nothing happens.
Here goes my JSF page:
Register.xhtml

<!DOCTYPE html>
<html lang="pt-br"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">

    <h:head>
        <title>TITLE</title>
    </h:head>

    <h:body>
         <h:form id="form">
            <h:panelGrid columns="3" >

                <h:outputLabel for="name"   value="Nome:" />
                <h:inputText   id="name"    value="#{register.person.name}"  >  
                    <f:ajax    event="blur" listener="#{register.validateName}" render="m_name" />
                </h:inputText>
                <rich:message  id="m_name"  for="name"  ajaxRendered="false"/>

                // some fields ..                    

                <h:outputLabel for="password" value="Password" />
                <h:inputSecret id="password" value="#{register.user.password}">
                    <f:validator validatorId="confirmPasswordValidator" />
                    <f:attribute name="confirm" value="#{confirmPassword.submittedValue}" />
                    <f:ajax event="blur" execute="password confirm" render="m_password" />
                </h:inputSecret>
                <rich:message id="m_password" for="password" />

                <h:outputLabel for="confirm" value="Senha (novamente):" />
                <h:inputSecret id="confirm" binding="#{confirmPassword}" >
                    <f:ajax event="blur" execute="password confirm" render="m_password m_confirm" />
                </h:inputSecret>
                <rich:message id="m_confirm" for="confirm" />

                <h:commandButton value="Register" action="#{register.registerPerson}" >
                    <f:ajax execute="@form" render="@form" />
                </h:commandButton>

                <h:outputText value="#{register.recordStatus}" id="out"  />
                <a4j:status>
                    <f:facet name="start">
                        <h:graphicImage name="loader.gif" library="image"/>
                    </f:facet>
                </a4j:status>    
        </h:panelGrid>
    </h:form>
    </h:body>
</html>

So when I fill the form and try to register, nothing happens, not even any exception it’s lauched.

The passwod validator (thanks BalusC mate):

@FacesValidator("confirmPasswordValidator")
public class ConfirmPasswordValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        String password = (String) value;
        String confirm = (String) component.getAttributes().get("confirm");

        if (password == null || confirm == null) {
            return; // Just ignore and let required="true" do its job.
        }

        if (!password.equals(confirm)) {
            throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
        }else{
            throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
        }
    }

}

I think this problem is very weird, I really don’t know what’s happening here.
Thanks guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:32:01+00:00Added an answer on May 25, 2026 at 5:32 pm

    You threw a ValidatorException on a succesful match.

    if (!password.equals(confirm)) {
        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
    } else {
        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
    }
    

    This causes JSF to block the form submit. The severity doesn’t matter. A validator exception is a validator exception. It indicates a vaildation failure.

    Rather use FacesContext#addMessage() instead.

    if (!password.equals(confirm)) {
        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "password not equal"));
    } else {
        context.addMessage(component.getClientId(), new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a windows form project and having some problem with UserControl
I am having some trouble with this code . The problem is when i
I'm having a problem with some code I've written. I've had to anonymize it,
I'm having a problem with some code that used to work in PHP 4.X
I'm trying to write my own Custom Validation attribute but I'm having some problems.
I´m started to work with AutoMapper today... But I´m having some problem with Dropdown
I seem to be having a problem. I want to write some code that
im having some problem with this code: if (count($_POST)) { $username = mysql_real_escape_string($_POST['username']); $passwd
I'm having a problem with QNetworkAccessManager. Here is some brief description of what I
I'm having some problem with MKMapView / annotations / UINavigationController. Basically, i manage my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.