Hello,
I am having an issue with Out of Sync errors. In my application, there exists a side panel in which I have buttons that update another panel with information related to the button the user clicks on. I’ve recently upgraded to the the nightly build of vaadin-6.5.0.nightly-20110107-c16808.jar and I’ve noticed that “Out of Sync” errors are occurring when I click between the buttons too fast. When I click a button the following behaviour takes place:
- Clear out the vertical layout for the information panel using layout.removeAllComponents();
- Pull the information related to the button and add components to the layout.
The problem is that for polling components - if the components are added to the layout and then I click another button which removes the components before the server finishes sending an update to the client, an “out of sync” error appears. I am using two different polling components - a custom component that I’ve built and I’m also using the SuperImmediateTextField (a custom component built by one of the folks at Vaadin).
Here is a screenshot of the portion of the application that is experiences this problem. The buttons are on the left side:
The code related to polling for my custom component is below:
@Override
protected void onAttach() {
super.onAttach();
if (pollerSuspendedDueDetach) {
poller.run();
}
}
@Override
protected void onDetach() {
super.onDetach();
poller.cancel();
pollerSuspendedDueDetach = true;
}
class Poller extends Timer {
@Override
public void run() {
if (refreshCount > MAX_REFRESH_COUNT) {
poller.cancel();
return;
}
// Just send something, to trigger the server side event.
client.updateVariable(client.getPid(getElement()),
VARIABLE_REFRESH_EVENT, 0, false);
client.sendPendingVariableChanges();
refreshCount++;
}
}
The code related to polling for the SuperImmediateTextField is below:
private Timer newTimer() {
return new Timer() {
public void run() {
sendSuperImmediateEvent();
timer = null;
}
};
}
public void sendSuperImmediateEvent() {
client.updateVariable(client.getPid(this), PROPERTY_KEYPRESSED, true,
false);
client.updateVariable(client.getPid(this), "text", getText(), false);
client.sendPendingVariableChanges();
}
@Override
protected void onDetach() {
super.onDetach();
if (timer != null) {
timer.cancel();
}
}
I believe the “onDetach()” should take care of stopping the “polling” from occurring and stop any further server-client updates to be sent. Were additional “out of sync” tests added to Vaadin as I do not remember having this problem before (I was using Vaadin 6.4.3 previously) and if so, is there a way around this?
Thanks for you help,
Ajay