JSF - Custom validator executed, no problems found, but execution flow does not arrive in Managed Bean

Asked

Viewed 356 times

0

I created a Custom Validator, referenced it in a <h:inputText>, Validator runs, no exception is raised, but the execution flow does not arrive in Managed Bean.

Where I must be going wrong?

<h:inputText id="cpf" size="18" maxlength="14" rendered="true" value="#{managedBean.usuario.CPF}">
  <c:validator validatorId="cpfValidator" />
</h:inputText>

package br.web.jsf.validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import br.util.BibliotecaMetodos;

@FacesValidator("cpfValidator")
public class CPFValidator implements Validator {
	
	@Override
	public void validate(FacesContext pFacesContext, UIComponent pUiComponent, Object pObject) throws ValidatorException {
		String cpf = (String) pObject;
		
		if ( !BibliotecaMetodos.isCPFvalido(cpf) ) {
			FacesMessage mensagem = new FacesMessage("O CPF é Nulo ou Inválido.");
			mensagem.setSeverity(FacesMessage.SEVERITY_ERROR);
			
			throw new ValidatorException(mensagem);
		}
	}
	
}

  • from a look at the console, maybe Voce is having validation problem in another field, or some other problem, probably should appear some error in the console, anything that can not identify the error in the console, edit your question and post the content here in the forum

  • Here’s the question. Console doesn’t print a line even after running Validator, leaving no clue. :/

  • 1

    I discovered another validation with problems, but that was silently stopping the execution . Here’s the tip, check other Validations

  • That’s exactly what I wanted Voce to play, not always its custom validation is the problem there may be other validations and these are causing the problem.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.