Field.ValueChangeEvent -- How is this ever used?

From what I can tell, the API for TextField and such only involves
, not

So when does Field.ValueChangeEvent come into play?

I would like to be receiving Field.ValueChangeEvent events, so I can get back to the UI component that the user manipulated.

–Basil Bourque

Property.ValueChangeEvent is an interface, which is implemented by several concrete event types. So by the API you should not be interested by the source of the event. However in reality it would be very convenient to know it. You could cast the event to Field.ValueChangeEvent. (ugly)

I see. Thanks for the answer.

This interface is what is used by the event mechanisms in Vaadin:


And the implementations actually used may be either:



So, when you receive a Property.ValueChangeEvent, you can try casting it to either of those Field. or Label. implementations. After casting to the Field. implementation, you have access to the extra methods such as “getComponent”.

Example method:

 * Implements Property.ValueChangeListener
 * @see
public void valueChange( ValueChangeEvent event ) {
    System.out.println( "DEBUG - The Application's 'valueChange' method is executing." + new java.util.Date() );

    if ( event instanceof Field.ValueChangeEvent ) {
        System.out.println( "DEBUG - Yes, event passed is a Field.ValueChangeEvent." );
        Field.ValueChangeEvent fieldEvent =[color=#01c63c]
[/color];  // [color=#1e95fd]
[/color] the Property.VCE interface to a Field.VCE implementation.
        Component sourceComponent = fieldEvent.[color=#01c63c]
[/color]; // After casting, access [color=#1e95fd]
additional methods
        if ( sourceComponent instanceof ) {
   validatable = ( ;
            boolean widgetIsValid = validatable.isValid(); // The goal in my particular use-case.