Showing and Editor's errors

61 views
Skip to first unread message

Alexander Orlov

unread,
Aug 8, 2012, 1:54:57 PM8/8/12
to google-we...@googlegroups.com
If an Editor doesn't satisfy an Entity's constraints, it calls

    driverCtx.fire(new Receiver<Void>() {
      @Override
      public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
        dialog.setText("Errors detected");
        Driver.DRIVER.setConstraintViolations(violations);
        List<EditorError> editorErrors = Driver.DRIVER.getErrors();
        for (EditorError editorError : editorErrors) {
          Logger.getLogger("editorError.getMessage(): ").log(Level.INFO, editorError.getMessage() + ""); // prints two constraint violations
        }
     }

Are the constraint violations visualized in some way? Because I don't see any visualizations....

Before firing the Receiver I do

    final RequestContext driverCtx = Driver.DRIVER.flush();
    if (Driver.DRIVER.hasErrors()) {
      dialog.setText("Invalid input");
      return;
    }

but Driver.DRIVER.hasErrors() remains always false although onConstraintViolation is executed when some fields are missing.

Jens

unread,
Aug 8, 2012, 2:12:17 PM8/8/12
to google-we...@googlegroups.com
Your editor views should implement HasEditorErrors and then you have access to the errors in your view so you can visualize them. As an example you can take a look at ValueBoxEditorDecorator which can wrap a ValueBox and displays any error for that ValueBox as a Label above the ValueBox.

Not sure about the next thing but I guess driver.hasErrors() only returns true if your Editor view implements HasEditorDelegate and you call delegate.recordError() in your view. You most likely use that if you implement ValueAwareEditor in your view so you can check the view's value when flush() is called.

-- J.
Reply all
Reply to author
Forward
0 new messages