I guess binder.getField() returns a TextField. So after TextUpper name = (TextUpper)binder.getField("name"); it'll be still a TextField, you can check this by
name instanceof TextUpper
The cast does not change its type. You only say "I know this is a TextUpper, a special type of TextField", but it isn't, you only made it look like. So if you do the cast and call methods afterwards, the object will still call the TextField's methods, and not the TextUpper ones. You have to create a new TextUpper, set the the text (and other values) from the TextField and use this object if you want to have its behaviour.
Or, just use
buildAndBind(String caption,
Object propertyId,
Class<T> fieldType)
with TextUpper :)
https://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha3/docs/api/com/vaadin/data/fieldgroup/FieldGroup.html#buildAndBind(java.lang.String, java.lang.Object, java.lang.Class)
Try this:
public TextUpper(Integer length){
super();
setMaxLength(length);
setImmediate(true);
setTextChangeEventMode(TextChangeEventMode.EAGER);
addTextChangeListener(this);
}
public TextUpper(){
super();
setImmediate(true);
setTextChangeEventMode(TextChangeEventMode.EAGER);
addTextChangeListener(this);
}
I have the strong feeling that buildAndBind calls the parameter less constructor, as you do not put the parameter for length anywhere