DateField max length

Hi all,
how can I set the maxLength of a DateField? As it is not a subclass of AbstractTextField but of AbstractField, the setMaxLength method is not available.

Any ideas how to realize that behavior?

Thanks and regards

Why setting the maxLength ?
Just set the width is usually enough…


I think the width is an optical value (e.g. 100px),
but maxLength should ignore the user input, when there are more letters than defined in maxLength ( maxLength =3, forth letter will not be shown/accpeted).
Compare Textfield component.

We don’t use DateField directly, but rather the InlineDateField or PopupDateField.

These give much better user experience in most cases…

Hmm, I also use PopupDateField as impl.

So, what do you do, when user enters in the (popup)datefield something like “201111111/04/21”?
Of course, the validation will fail, but wouldn’t it be nice to not allow more than 10 signs?

Often you want to e.g. paste something in a field that accepts text input and then edit the result, or if you have transposed digits, first add a digit at the correct place and then delete the extra one etc.

In general, text editing and corrections can become painful for keyboard-oriented people if input fields are too restrictive.

Hmm, but I still think, it should be possible to add a maxLength, so that the developer could decide wehther to use it or not. (for my purposes that feature would be required)
Do you think you could integrate it in one of the next versions?

Nothing will happen if there is no enhancement request in our Trac, but you could
create one
. I don’t think it would have a high priority, though.

If you have a Vaadin Pro Account subscription, you could
vote for the enhancement request
, or even
sponsor developing it

It might be small enough a task to do yourself as well, though, if you are not afraid of client-side programming - see the client side class VTextualDate. You might have to copy the class as the TextBox is stored in a private field.

Ticket created:

Hello, All!

Did you bring an issue to a close?
How to setMaxLength to PopupDateField?