0
我的印象是ValueBoxEditorDecorator會在文本框的右側顯示錯誤。我正在運行此代碼。當發現錯誤時,我會看到一個警告框,但ValueBoxEditorDecorator沒有顯示任何內容。ValueBoxEditorDecorator <String>不顯示錯誤
public class AddressEditor extends Composite implements Editor<Address>, HasEditorErrors<Address>
{
private static final Binder binder = GWT.create(Binder.class);
@UiField ValueBoxEditorDecorator<String> name;
interface Binder extends UiBinder<Widget, AddressEditor> {
}
public AddressEditor() {
initWidget(binder.createAndBindUi(this));
}
@Override
public void showErrors(List<EditorError> errors) {
name.showErrors(errors);
if (errors.size()>0)
{
StringBuilder sb = new StringBuilder();
for(EditorError e : errors)
{
sb.append(e.getMessage());
}
Window.alert(sb.toString());
}
}
這是XML的用戶界面。
<e:ValueBoxEditorDecorator ui:field="name">
<e:valuebox>
<g:TextBox/>
</e:valuebox>
</e:ValueBoxEditorDecorator>
編輯:
這是我的驗證檢測代碼。也許我正在擦除有關錯誤路徑文件的一些數據。
a = editorDriver.flush();
ValidatorFactory factory = Validation.byDefaultProvider().configure().buildValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Address>> violations = validator.validate(a);
@SuppressWarnings({ "unchecked", "rawtypes" })
Set<ConstraintViolation<?>> violations2 = (Set<ConstraintViolation<?>>) (Set) violations;
editorDriver.setConstraintViolations(violations2);