【问题标题】:GWT Editor Framework - Constraint Violations for nested Entities not publishedGWT 编辑器框架 - 未发布嵌套实体的约束违规
【发布时间】:2012-05-15 09:49:28
【问题描述】:

我对 gwt 的编辑器框架有问题。 在执行 editorDriver.setConstraintViolations(errors) 时,错误不会发布到使用嵌套实体的字段

首先我有一个用户实体:

public class User extends BaseEntity {

@OneToOne
@JoinColumn(nullable = false)
private Contact contact;

@NotNull(message = "username must not be null")
@Column(nullable = false)
private String username;
....

现在在我的编辑器中,我有像

这样的字段
@UiField 
ValidationWidgetDecorator<String> username;

@Path("contact.title")
@UiField
ValidationWidgetDecorator<String> title;

ValidatoinWidgetDecorator 类与 ValueBoxEditorDecorator 几乎相同

现在如果我在做

RequestContext context = editorDriver.flush();



    context.fire(new Receiver<Void>() {

         @Override
          public void onConstraintViolation(Set<ConstraintViolation<?>> errors) {
            editorDriver.setConstraintViolations(errors);
          }

    ...

显示 Userproxy 的约束错误(例如用户名违规)并且一切正常,但如果违规发生在联系人中(例如在 contact.title 字段中),则错误不会在视图中发布( showErrors(错误列表)中的错误容器为空)

现在我真的找不到其他人有这个问题,所以我想问题出在我这边,可能是因为我的编辑器实现了编辑器 并且联系人是 ContactProxy?

其他一切似乎都正常

希望有足够的代码,否则我会发布更多。

谢谢

【问题讨论】:

  • 错误列表中是否包含 contact.title 的错误。如果是,您可以在 ValidationWidgetDecorator 中放置断点以查看它是如何被视为错误的吗?

标签: gwt editor


【解决方案1】:

我怀疑问题是onConstraintViolation 没有为一般的context.fire 调用,而只是为保存项目的请求调用。当您在上下文中发出请求时,将 onConstrainViolation 覆盖移动到接收器(可能需要添加)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多