Implementing Textitem maximum width in Smart GWT 2.6

Asked

Viewed 36 times

0

At Smartgwt, I’m trying to make a MaxLength in a TextItem. This TextItem is in an editable field of a Grid. Below follows the code used.

How to do a validation on OnKeyPress which, when it reaches the established limit, does not allow the user to enter any more characters?

    final TextItem editorType = new TextItem();
    editorType.setLength(100);
    editorType.setEnforceLength(true);
    editorType.setValidateOnChange(true);
    editorType.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if(editorType.getValue().toString().length() > 100)
                event.cancel();
        }
    });
  • Please try to make descriptive titles in Portuguese. If you think you have a better one, feel free to [Dit] the question.

  • 1

    @Brasofilo well observed, had accustomed to the stack in English. Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.