The example below throws an ‘Out of sync’ error, when the focus is on the ‘Close’-Button and ‘ENTER’ is pressed.
The problem:
The method AbstractCommunicationManager.handleVariableBurst is called two times. The weird behaviour doesn’t occur, when the Thread sleeps a short period of time before the Tab is closed.
System used: Linux / Windows with Firefox Version 3.6 / 3.5.
With other browsers (Chrome, IE7 / 8 and Firefox 4 beta) the error does not occur.
Burst called with 837PID6heighti1680PID6widthi0PID13citruePID15stateb
OWNER FOR PID6 = class org.berlinger.vaadin.OutOfSyncExampleWindow
OWNER FOR PID13 = class com.vaadin.ui.TextField
OWNER FOR PID15 = class com.vaadin.ui.Button
--- close tab ---
Burst called with PID15PID9actiontargetp1PID9actions
OWNER FOR PID9 = - null -
23.02.2011 17:11:28 com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
WARNUNG: Warning: Ignoring variable change for non-existent component, VAR_PID=PID9
OWNER FOR PID9 = - null -
23.02.2011 17:11:28 com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
WARNUNG: Warning: Ignoring variable change for non-existent component, VAR_PID=PID9
The output above shows, that PID9 has no owner - as the Tab (Panel) is removed by the first call sent by browser.
I verified that, the owner of PID9 should be the class PanelWithHandler.
package example.outofsync;
import com.vaadin.Application;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ShortcutAction;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Form;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
public class OutofsyncApplication extends Application {
@Override
public void init () {
Window mainWindow = new Window("Outofsync");
Button openTestWindow = new Button("Open Test Window", new ClickListener() {
public void buttonClick (ClickEvent event) {
getMainWindow().addWindow(new OutOfSyncExampleWindow());
}
});
mainWindow.addComponent(openTestWindow);
setMainWindow(mainWindow);
}
/** */
public class OutOfSyncExampleWindow extends Window implements Handler, ClickListener {
private Form form;
Action m_actionOk = null;
/** */
public OutOfSyncExampleWindow() {
setWidth(400, UNITS_PIXELS);
setHeight(200, UNITS_PIXELS);
m_actionOk = new ShortcutAction("Default key", ShortcutAction.KeyCode.ENTER, null);
Button closeButton = new Button("Close", (ClickListener) this);
closeButton.focus();
form = new Form();
form.addField("test", new TextField("Foo"));
form.getFooter().addComponent(closeButton);
addComponent(form);
addActionHandler(this);
center();
}
/** */
public void buttonClick (ClickEvent event) {
close();
}
/** */
public Action[] getActions (Object target, Object sender) {
if (sender == this)
{
return new Action[] {m_actionOk};
}
return null;
}
/** */
public void handleAction (Action action, Object sender, Object target) {
if (action == m_actionOk) {
close();
}
}
}
}
Is this a bug or a limitation? Is there a way to prevent this problem?
The same Message is thrown, if the class PanelWithHandler is implemented as a sub Window, closed by pressing Enter on the Close Button.