0
votes

I have a problem with the Editor Framework of gwt. when doing editorDriver.setConstraintViolations(errors), errors are not published to fields which use nested entities

First i have a User Entity:

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;
....

Now in my editor i have fields like

@UiField 
ValidationWidgetDecorator<String> username;

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

ValidatoinWidgetDecorator Class is pretty much the same like the ValueBoxEditorDecorator

now if im doing

RequestContext context = editorDriver.flush();



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

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

    ...

the constraint errors for the Userproxy(for example violation on username) are shown and everything works good, but if the violation happens in the contact (for example at contact.title field), the errors dont get published in the view (errors container in showErrors(List errors) is empty)

Now i cant really find someone else with this issue so i guess the problem is on my side, maybe cause my editor implements Editor < UserProxy > and the contact is a ContactProxy?

everything else seems to work right

hope its enough code , otherwise im gonna post some more.

Thx

1
does the list of errors contain an error for contact.title.. and if so, can you put breakpoint in the ValidationWidgetDecorator to see how it is being treated as an error ? - koma

1 Answers

0
votes

I suspect the issue is that onConstraintViolation isn't invoked for the general context.fire, but only for the request that saved the items. Move the onConstrainViolation override to the receiver (which may need to be added) when you made the request on the context.