List of usage examples for org.apache.wicket.validation IValidatable getModel
IModel<T> getModel();
From source file:net.ftlines.wicket.validation.bean.PropertyValidator.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from w ww . ja v a 2s .c om public void validate(IValidatable<T> validatable) { ValidationContext context = ValidationContext.get(); IProperty property = null; if (this.property instanceof IProperty) { property = (IProperty) this.property; } // allow property resolver to resolve the property if (property == null && this.property != null) { property = context.resolveProperty(this.property); } if (property == null && validatable.getModel() != null) { property = context.resolveProperty(validatable.getModel()); } if (property == null) { throw new IllegalStateException("Could not resolve IProperty to validate and none were provided"); } IGroups groups = this.groups != null ? this.groups : IGroups.NONE; Class type = property.getContainerType(); Set<ConstraintViolation<Object>> violations = context.getValidator().validateValue(type, property.getName(), validatable.getValue(), groups.getGroups()); for (ConstraintViolation<Object> violation : violations) { validatable.error(context.convert(violation)); } }