1 package org.whatsitcalled.webflange.webapp; 2 3 import org.apache.wicket.validation.IValidatable; 4 import org.apache.wicket.validation.ValidationError; 5 import org.apache.wicket.validation.validator.StringValidator; 6 import org.quartz.CronExpression; 7 8 public class CronValidator extends StringValidator { 9 String message; 10 11 public CronValidator(String message) { 12 this.message = message; 13 } 14 15 @Override 16 protected void onValidate(IValidatable val) { 17 String cron = (String)val.getValue(); 18 if (!CronExpression.isValidExpression(cron)) { 19 ValidationError error = new ValidationError(); 20 error.setMessage(message); 21 val.error(error); 22 } 23 } 24 25 26 }