1 package dinamica.validators; 2 3 import java.util.HashMap ; 4 import javax.servlet.http.HttpServletRequest ; 5 import dinamica.*; 6 7 20 public class DateRangeValidator extends AbstractValidator 21 { 22 23 26 public boolean isValid( 27 HttpServletRequest req, 28 Recordset inputParams, 29 HashMap attribs) 30 throws Throwable 31 { 32 33 String date1 = (String )attribs.get("date1"); 34 String date2 = (String )attribs.get("date2"); 35 36 if (date1==null || date2==null) 37 throw new Throwable ("Invalid attributes 'date1' or 'date2' - cannot be null."); 38 39 java.util.Date d1 = (java.util.Date )inputParams.getValue(date1); 40 java.util.Date d2 = (java.util.Date )inputParams.getValue(date2); 41 42 if (d1!=null && d2!=null && d2.compareTo(d1) < 0 ) 43 return false; 44 else 45 return true; 46 47 } 48 49 } 50 | Popular Tags |