We are using Client only Datasource in our application. Based on the data entered on combobox item, we call fetchData and see if data exists in DataSource. If not, then we call rest service to get data from DB (records starting with text entered in combo box).
local Function which calls datasource fetchData is called from combobox change handler.
Our issue here is, before execution of this local function (specifically fetch data) completes, next piece of code in the changehandler is getting called and thats creating various issues.
Any insight on this?
private void lookupSpecificDs() {
String criteria = display.getSpecificTAItem().getValue().toString().trim();
faSpecificDataSource.fetchData(new Criteria("name", criteria),
new DSCallback() {
public void execute(DSResponse response, Object rawData,
DSRequest request) {
Record[] records = (Record[]) response.getData();
if (records.length > 0) {
contentID = records[0].getAttribute("id");
System.out.println("**** contentID in lookup: " + contentID);
}
}
});
Above code is getting called from change handler,
display.getSpecificTAItem().addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
contents = (String) event.getItem().getValue();
if (contents != null && contents.length() >= MINI_LENTH) {
contents = contents.toUpperCase();
lookupSpecificDs();
System.out.println("contentID: "+contentID);
}
}
});
Here we are seeing "contentID: " log from change handler even before previous method execution is complete.
local Function which calls datasource fetchData is called from combobox change handler.
Our issue here is, before execution of this local function (specifically fetch data) completes, next piece of code in the changehandler is getting called and thats creating various issues.
Any insight on this?
private void lookupSpecificDs() {
String criteria = display.getSpecificTAItem().getValue().toString().trim();
faSpecificDataSource.fetchData(new Criteria("name", criteria),
new DSCallback() {
public void execute(DSResponse response, Object rawData,
DSRequest request) {
Record[] records = (Record[]) response.getData();
if (records.length > 0) {
contentID = records[0].getAttribute("id");
System.out.println("**** contentID in lookup: " + contentID);
}
}
});
Above code is getting called from change handler,
display.getSpecificTAItem().addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
contents = (String) event.getItem().getValue();
if (contents != null && contents.length() >= MINI_LENTH) {
contents = contents.toUpperCase();
lookupSpecificDs();
System.out.println("contentID: "+contentID);
}
}
});
Here we are seeing "contentID: " log from change handler even before previous method execution is complete.
Comment