Pregunta

Using the Editor framework I found that you have to do client side validation yourself. Here is a question that deals with this topic.

Do I really have to write all this code when I want to integrate the client side validation with the editor framework?

Person newPerson = editorDriver.flush();

Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Person>> violations = validator.validate(newPerson, Default.class);

@SuppressWarnings({ "rawtypes", "unchecked" })
Iterable<ConstraintViolation<?>> tmpViolations = (Iterable<ConstraintViolation<?>>) (Set) violations;

if (!violations.isEmpty()) {
    editorDriver.setConstraintViolations(tmpViolations);
}
¿Fue útil?

Solución

Yes.

That's one of the differences between libraries/toolkits and frameworks: the formers are lighter and less intrusive but require more glue code.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top