2012-05-15 21 views
0

我有gwt编辑器框架的问题。 做editorDriver.setConstraintViolations(错误)时,错误不被发布到其使用嵌套的实体GWT编辑器框架 - 未发布嵌套实体的约束违规

首先我有一个用户实体领域:

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(列表错误)是空的)

现在我真的找不到这个问题的其他人,所以我想问题是在我身边,也许导致我的编辑器实现编辑器< UserProxy>和联系是一个ContactProxy?

一切似乎工作的权利

希望它足够的代码,否则我也会发布更多一些。

THX

+0

错误列表是否包含contact.title错误?如果是这样,您可以在ValidationWidgetDecorator中放置断点来查看错误是如何处理的? – koma

回答

0

我怀疑的问题是,onConstraintViolation不调用对于一般context.fire,但仅适用于保存的项目的请求。当您在上下文中提出请求时,将onConstrainViolation覆盖移至接收方(可能需要添加)。