Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. @FacesValidator("primeDateRangeValidator")
  2. public class PrimeDateRangeValidator implements Validator{
  3.      @Override
  4.     public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
  5.         if (value == null) {
  6.             return;
  7.         }
  8.          
  9.         //Leave the null handling of startDate to required="true"
  10.         Object startDateValue = component.getAttributes().get("finicial");
  11.         System.out.println("Fecha Obtenida: "+startDateValue);
  12.         if (startDateValue==null) {
  13.             return;
  14.         }
  15.          
  16.         Date startDate = (Date)startDateValue;
  17.         Date endDate = (Date)value;
  18.         if (endDate.before(startDate)) {
  19.              FacesMessage message = new FacesMessage("La fecha Final no puede ser anterior a la fecha Inicial.");
  20.             message.setSeverity(FacesMessage.SEVERITY_ERROR);
  21.             throw new ValidatorException(message);
  22.         }
  23.     }