Search code examples
javagwtgxtuibinder

gxt, gwt, Java. Validation of textfield without infobubble


I have to check some textField with the following rule:

if (the value A != the value B) {
  this.A.forceInvalid("");
}

This work really fine, but I want to remove the "info bubble" of the error,on the textfield. I have tried to simply put a css with red border around it, but it seems that my superior dont want that.

How can I erase that bubble?


Solution

  • First of all, this validation looks wrong. It seems you are using gxt Field which already has built-in validators. Here is an example:

    yourField.addValidator(new Validator<String>() {
    
      @Override
      public List<EditorError> validate(Editor<String> editor, String value) {
        final List<EditorError> errors = new ArrayList<EditorError>();
        if (!value.equals("test")) {
          errors.add(new DefaultEditorError(yourField, "Value is not \"test\"", value));
        }
        return errors;
      }
    });
    

    By default it looks like this: buble validation You can change it by using non-default ErrorHandler on the field. It is not clear what exactly do you want, as far as I can understand you want to get rid of (!) sign and its popup. I think that TitleErrorHandler will suit your needs.

    yourField.setErrorSupport(new TitleErrorHandler(yourField));
    

    simple error