This content has been marked as final.
Show 1 reply
-
1. Re: Null Pointer Exception EqualityValidator
flavioborsatto Apr 12, 2010 10:00 PM (in response to flavioborsatto)public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if (getFor() == null) { throw new FacesException("Must specify a component to validate equality against"); } UIComponent otherComponent = findOtherComponent(component); Object other = new OtherComponent(context, otherComponent).getValue(); if (value == null && other == null) *// THIS SHOULD BE AN || ?????* { // Thats fine } else if (value != null) { switch (operator) { case EQUAL: if (!value.equals(other)) { throwValidationException(value, otherComponent, other); } break; case NOT_EQUAL: if (value.equals(other)) { throwValidationException(value, otherComponent, other); } break; case GREATER: if (!(compare(value, other) > 0)) { throwValidationException(value, otherComponent, other); } break; case GREATER_OR_EQUAL: if (!(compare(value, other) >= 0)) { throwValidationException(value, otherComponent, other); } break; case LESS: if (!(compare(value, other) < 0)) { throwValidationException(value, otherComponent, other); } break; case LESS_OR_EQUAL: if (!(compare(value, other) <= 0)) { throwValidationException(value, otherComponent, other); } break; } } }