1 package org.whatsitcalled.webflange.webapp;
2
3 import org.apache.log4j.Logger;
4 import org.apache.wicket.validation.IValidatable;
5 import org.apache.wicket.validation.ValidationError;
6 import org.apache.wicket.validation.validator.StringValidator;
7
8 public class ChoiceRequiredValidator extends StringValidator {
9 private static Logger LOGGER = Logger.getLogger(ChoiceRequiredValidator.class);
10 String message;
11
12 public ChoiceRequiredValidator(String message) {
13 this.message = message;
14 }
15 @Override
16 public void onValidate(IValidatable val) {
17 if (val.getValue() == null) {
18 ValidationError error = new ValidationError();
19 error.setMessage(message);
20 val.error(error);
21 return;
22 }
23 }
24 @Override
25 public boolean validateOnNullValue() {
26 LOGGER.debug("DDCValidator checking null value:");
27 return true;
28 }
29 }