ComboBox filtering value

Hi everyone!
Suppose I have combobox with allowed input.
I want to limit input, for example user can enter only 10 characters .
How can I do it?

For best user experience there are 2 possible ways:

  1. Extend current ComboBox, it’s ComboBoxConnector, the VFilterSelect widget and the ComboBoxState. Then follow the implementation from AbstractTextField.setMaxLength(int). So you check the length on the client side. This way you avoid useless events.
  2. Might work if you only create an extension for the ComboBox and then, instead of extending all ComboBox classes, maybe you can just access the text element in the browser and prevent the key event when the text length exceed a certain value you set on the extension object you create.

Othewise maybe you can just listen to ComboBox serverside events, but that won’t look nice because you have client - server communication which will add delay.