EventBus and Vaadin (syncronization?)

Hi,

i m using Bushe´s Eventbus in a vaadin appliction (the ThreadSaveEventService). However, there seems to be a syncronization problem:

(1) I send the “Open Window” Event on a Button-Click Listner
(2) I receive the event (println() displays the message)
(3) But the window does not open …

I use the following code …

    public Window openWindow(MoListView view){
    	Window win = new MoListViewEditor(view);
		
		win.setWidth("90%");
		win.setHeight("90%");
		win.center();
		win.setModal(true);
		getMainWindow().addWindow(win);
		
		System.out.println("FlatplierApplication / openWindow: window added " + view.getListViewTitle());
		getMainWindow().showNotification("FlatplierApplication / openWindow called");
		
		
		
		return win;
    }
    
    public void onEvent(SelectEntityEvent ev) {
    	System.out.println("FlatplierApplication / onEvent " + ev.getMsg());
    	
    	if (ev.getMsg().equals("open")) {
    		openWindows.put(ev.getView(), openWindow(ev.getView()));
    	}

How should i syncronized the ui-thread? Or should i simply call repaint? If i call getMainWindow().notify() after the addWindow() call, i get a long stack trace ( java.lang.IllegalMonitorStateException) …

Any help appreciated … thanks a lot,
Dan

Hi,

  1. You should synchronize on the application instance; you may need to use the ThreadLocal application pattern, as detailed here http://vaadin.com/wiki/-/wiki/Main/ThreadLocal%20Pattern

  2. You need to find a way to update the client (browser). In vaadin, almost all of the UI updates happen as part of the standard request-response cycle - the user does something in the browser, the event/data is sent to the server, the server updates the UI, and the updated UI is sent back to the client. Using a different thread to update the UI (as with using the ThreadSafeEventService) means that there is no http “response” to send the updated UI back to the client.

So : you need to either use either the
IcePush
or
Refresher
add-on.

Thanks for posting this, btw : I, too, am using Bushe’s Eventbus, and have realised that I have forgotten to do this. I guess I better get IcePush working in this project!

HTH a little,

Cheers,

Charles.