Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FacesValidator("primeDateRangeValidator")
- public class PrimeDateRangeValidator implements Validator{
- @Override
- public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
- if (value == null) {
- return;
- }
- //Leave the null handling of startDate to required="true"
- Object startDateValue = component.getAttributes().get("finicial");
- System.out.println("Fecha Obtenida: "+startDateValue);
- if (startDateValue==null) {
- return;
- }
- Date startDate = (Date)startDateValue;
- Date endDate = (Date)value;
- if (endDate.before(startDate)) {
- FacesMessage message = new FacesMessage("La fecha Final no puede ser anterior a la fecha Inicial.");
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- throw new ValidatorException(message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement