Guava EventBus and strange effect

Hello Everyone!

I am struggling with very strange behaviour in my Vaadin 7 application. I have my UI where I initialize my EventBus. Also this UI is responsible for changing layout if user is authorized by Active Directory. I have class LoginView which extends VerticalLayout. On this layout there are simple TextFiled and PasswordField and submit Button. On ClickListener I want to add class to this layout (simple showing spinner that action is working) and I pos LogginEvent on EventBus. This LoggingEvent is subscribe in my UI class where I check in Active Directory user and whether user is found I navigate user to real application with correct views and navigator. If user is not found I remove class with spinner and show Notification. The problem is following:
When I click submit, class is not added to this layout. It is added right after flow of execution is returning from execution of posting Event on Bus. Does anyone know why Vaadin does not add this class?
I attach two of my classes.

Hope you will help me! :slight_smile:

Looking forward to hearing from you! :slight_smile:

Kamil

P.S. This mechanism was written based on Vaadin Dashboard code.
20984.java (4.52 KB)
20985.java (3.03 KB)

Manual Push did a trick! :slight_smile:

signin.addClickListener(new ClickListener() {
    @Override public void buttonClick(final ClickEvent event) {
        LoginView.this.addStyleName("loading");
        UI.getCurrent().push();
        KPSUI.getKPSEventbus().post(new KPSEvent.UserLoginRequestedEvent(username.getValue(), password.getValue()));
    }
});

Yes, with automatic push the changes are only pushed once the session is unlocked (in this case once the current request ends, just like with regular HTTP.)