DynamicForm saveData() lag

Hello.

I am using a form to edit data from an RPC data source (using setTestData(..)) and it works fine but when I want to submit my pojo to the server, I do:

// here datasource is not the same as fields edited in form
dynamicForm.saveData();
// here datasource should have the new values from form
myDataSource.saveToPojo(); // here I copy from getTestData(); to my pojo's
sendPojosToServer();

But it sends my pojos with the unedited, old values.

But now if I do:

dynamicForm.saveData();
new Timer() {
	public void run() {
		// here datasource has the new values!!
		myDataSource.saveToPojo();
		sendPojosToServer();
	}
}.schedule(10);

Why when it finishes the call to dynamicForm.saveData(); the changes are not done?

DynamicForm.saveData is an asynchromous call. Use the version with a callback and place the rest of your code in the callback.

DynamicForm.saveData(DSCallback)

Javadocs for this method need to be added but for now you can refer to the SC docs for this method.

Sanjiv

Well that just did it, thanks for the tip.

dynamicForm.saveData(new DSCallback() {
	public void execute(DSResponse response, Object rawData, DSRequest request) {
		myDataSource.saveToPojo();
		sendPojosToServer();
	}
}