Howdy,
There's nothing at this point that's elegant, but if you don't need a
value model then you can add something like the following to your form
model. It's a bit ugly but should hopefully work (I haven't tested
it).
public class MyFormModel extends FormModel {
public ArrayList<Field<?>> getInvalidFields() {
ArrayList<Field<?>> fields = new ArrayList<Field<?>>();
for (Field<?> field : allFields()) {
if (hasErrors(field)) {
fields.add(field);
}
}
return fields;
}
private boolean hasErrors(Field<?> field) {
ValidationManager validationManager =
getValidationManager(this);
if (field instanceof FieldModel) {
return validationManager.getValidator((FieldModel<?>)
field).getValidationResult().contains(Severity.ERROR);
} else if (field instanceof ListFieldModel) {
return validationManager.getValidator((ListFieldModel<?>)
field).getValidationResult().contains(Severity.ERROR);
}
// should probably barf here as we found a field type we don't
know about...
throw new IllegalStateException("Unknown field type: " +
field.getClass().getName());
}
Cheers
Andrew