标签: gwt-validation

如何使用客户端Validator Validate方法调用的返回值在EditorDriver上设置ConstraintViolations

使用GWT 2.5.0,我想使用客户端验证和编辑器.尝试将ConstraintViolation java.util.Set传递给EditorDriver时遇到以下错误,如下所示.

Validator a = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Person>> b = a.validate(person);
editorDriver.setConstraintViolations(b);
Run Code Online (Sandbox Code Playgroud)

The method setConstraintViolations(Iterable<ConstraintViolation<?>>) in the type EditorDriver<Person> is not applicable for the arguments (Set<ConstraintViolation<Person>>)

我能找到的唯一有点相关的帖子是问题6270!

下面是一个示例,它带有一个带有Person Editor的PopUpDialog,允许您指定一个名称并根据您的注释对其进行验证.在personDriver.setConstraintViolations(violations);PersonEditorDialog中注释掉该行将允许您运行该示例.

我没有足够的声誉点来发布示例的图像.


public class Person {

@NotNull(message = "You must have a name")

@Size(min = 3, message = "Your name must contain more than 3 characters")

private String name;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

} …
Run Code Online (Sandbox Code Playgroud)

gwt gwt-editors gwt-validation

5
推荐指数
1
解决办法
1158
查看次数

标签 统计

gwt ×1

gwt-editors ×1

gwt-validation ×1