Okay, I found that if my callback doesn’t say it’s immediate, I can avoid the recursive calls to ApplicationConnection.sendPendingVariableChanges().
But what I see now is that it appears my button is being sent along with the new data values, which I can see in this GWT debug statement:
00:09:52.254 [INFO]
Making UIDL Request with params: cb18fb07-6504-492f-9c02-60e7338cf3detruePID119stateb1,249,863,false,false,false,false,1,51,9PID119mousedetailss<h1>aaa</h1> PID132texts
PID132 is my widget paintableId, the field name is ‘text’ and the value sent is ‘
aaa
’. But somehow, on the server side, my Form is processing the SAVE button click before my field is updated since when I call Form.commit() the field still shows the old value. And only then do I see my server-side component’s changeVariables() callback being called. So, while it seems I’m sending along my data with that request, the Form is processing the button before my server-side widget is being updated by the changeVariables() call.
Unfortunately, ApplicationConnection.pendingVariables is private, so I cannot use my subclass to ensure my widget values are before others in the ArrayList. I think the server side is just processing them in order, so the button is firing before my data update. It’s sad that so many classes use private instead of protected, thus making it impossible to subclass when subclassing is what makes object oriented programming so cool.
What might I be missing in trying to hook into the ApplicationConnection? My current subclass is even simpler now:
public class MyApplicationConnection extends com.vaadin.terminal.gwt.client.ApplicationConnection {
LinkedList<VCKEditorTextField> editorList = new LinkedList<VCKEditorTextField>();
public void addEditor(VCKEditorTextField editor) {
synchronized(editorList) {
if ( ! editorList.contains(editor) )
editorList.add(editor);
}
}
public void removeEditor(VCKEditorTextField editor) {
synchronized(editorList) {
editorList.remove(editor);
}
}
@Override
public void sendPendingVariableChanges()
{
synchronized(editorList) {
for( VCKEditorTextField editor : editorList )
editor.checkIfNeedsToSendToServer();
}
// Do the real one!
super.sendPendingVariableChanges();
}
}