TextField Extension

I’m trying to block completely the input of a number in a field. I don’t want to invalidate the field, but rather not let the user type the number in the field at all.
I have tried to do this with an extension of TextField, but I don’t know if I’m doing something wrong or my concepts are wrong. The textField just behaves like a normal TextField.
I created two files: AlphaField and AlphaFieldConnector. The Connector class is in a folder called client in the same level as my Widgetset. When I compile the Widgetset I can see that is going through that file, but should I add anything else to MyWidgetSet.gwt.xml? I tried to add , but that doesn’t solve anything either.

Here is the code:

public class AlphaField extends AbstractExtension
  public static void extend(TextField field)
    new AlphaField().extend((AbstractClientConnector) field);
public class AlphaFieldConnector extends AbstractExtensionConnector
  private static final long serialVersionUID = -737765038361894693L;

  @Override protected void extend (ServerConnector target)
    final VTextField textField = (VTextField) ((ComponentConnector) target).getWidget();

    KeyPressHandler keyPressHandler = new KeyPressHandler()
      @Override public void onKeyPress (KeyPressEvent event)


Just for simplicity and testing, what this should do (in my mind :P) is that when I type inside the extended component, nothing is written. This is how I use the component:

TextField textField = new TextField(); AlphaField.extend(textField); addComponent(textField); Any idea of why is this not working? Do I have the concept totally wrong?

Your code works for me in Google Chrome and Edge.

Do you have any errors in your browser inspector log? Maybe your UI is using the wrong widgetset?

This is my widgetset xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
    <inherits name="com.vaadin.DefaultWidgetSet"/>

I don’t have any error in the inspector log, but when I use the Vaadin debug, I see that the field is added has TextFieldConnector as connector. Is this correct or should it have AlphaFieldconnector? How can I make sure that my Widgetset is being used?

Ok, so my coworker removed the use of the custom widgetset from the web.xml. Since this was the first time I was creating an extension I thought it was my fault. Thank you very much for your help, you pointed me to search for other problems than the implementation :slight_smile:

Just for future reference in the Vaadin debug for that component, the connectior is still TextFieldConnector