Example usage for com.vaadin.client ServerConnector addStateChangeHandler

List of usage examples for com.vaadin.client ServerConnector addStateChangeHandler

Introduction

In this page you can find the example usage for com.vaadin.client ServerConnector addStateChangeHandler.

Prototype

public HandlerRegistration addStateChangeHandler(StateChangeHandler handler);

Source Link

Document

Adds a handler that is called whenever any part of the state has been updated by the server.

Usage

From source file:com.mcparland.john.vaadin_mvn_arch.client.samples.ResetButtonForTextFieldConnector.java

License:Apache License

@Override
protected void extend(ServerConnector serverConnector) {
    serverConnector.addStateChangeHandler(new StateChangeEvent.StateChangeHandler() {
        /**//  w  w w  .  java  2 s.c om
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onStateChanged(StateChangeEvent stateChangeEvent) {
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    updateResetButtonVisibility();
                }
            });
        }
    });

    textField = (VTextField) ((ComponentConnector) serverConnector).getWidget();
    textField.addStyleName(CLASSNAME + "-textfield");

    resetButtonElement = DOM.createDiv();
    resetButtonElement.addClassName(CLASSNAME + "-resetbutton");

    textField.addAttachHandler(this);
    textField.addKeyUpHandler(this);
}