custom validator not working !!

I used the following code inside the pagebeanView.java for the custom validator, to compare two dates, but the validator doesn’t work when I click the submit button, but when I click the submit button next time, it works. I changed the page bean scope from session to request, but still the problem persits. I don’t know the reason for this weird behavior. Can you please check this code and suggest me if I am going wrong somewhere?

Thanks
Venu

public void dateInput_validator(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value) {
// TODO: Check the value parameter here, and if not valid, do something like this:
//throw new ValidatorException(new FacesMessage(“Not a valid value!”));
DateInput test =(DateInput)this.findComponentInRoot(“defaultForm:dateInput1”);
DateInput effdt =(DateInput)this.findComponentInRoot(“defaultForm:dateInput”);
java.util.Date exprdte = (java.util.Date)test.getValue();
java.util.Date effdte = (java.util.Date)effdt.getValue();
if(exprdte!=null && effdte!=null){

		if(exprdte.before(effdte)){
			
			throw new ValidatorException(new FacesMessage("Not XXXX!"));
		}
	}