我正在使用 GWT 编辑器和 javax 验证。
我有一个带有像这样的子 bean 的模型 bean ->
public interface BeanA {
@Valid
BeanB getBeanB();
void setBeanB(BeanB b);
}
public interface BeanB {
@NotEmpty
public String getValue();
public void setValue(String value);
}
有一个实现 LeafValueEditor、HasEditorErrors 接口的 Widget。
该值似乎毫无问题地具有约束力。
public class MyWidget extends Composite implements
LeafValueEditor<String>, HasEditorErrors<String>{
...
@Override
public void showErrors(List<EditorError> errors) {
// Even though the error is flagged
// the errors collection does not contain it.
}
}
当我调用 validate 并且小部件 getValue 返回 null 时,ConstraintViolation 集合包含错误,但是当调用 showErrors 时,List 为空。
知道为什么发现违规但没有出现在小部件 showErrors 中吗?