views:

43

answers:

2

So essentially this project builds a portal of testing results from various test types. The fetching and display of results is fine; however, the resulting tables are not being displayed in the correct order. The order they're displayed in is random, but it's clearly specified the order in which the RPC calls are dispatched and I even implemented an indexing system in my panel to further assist.

Basically, the application consists of three horizontal panels contained within a verticalpanel.

further explanation: new, mid, and old refer to three versions of the software product being tested. A TestTable is just a custom FlexTable, and each of the xxxPanels are HorizontalPanels. The indices are all initialized at zero outside of the onModuleLoad() method. Each panel has its own service tasked with dispatching RPC calls to populate the corresponding panel.

public void onSuccess(List<TestResult> result) {

TestTable testTable1 = new TestTable(result);

if(result.get(0).getVrmf().equals(newestVersion)){
 newPanels.insert(testTable1, newIndex + 1); //insert adds element BEFORE specified index, so +1
 newPanels.addStyleName("horizontalPanelStyle");
 newIndex++;
}

if(result.get(0).getVrmf().equals(middleVersion)){
 midPanels.insert(testTable1, midIndex + 1); //insert adds element BEFORE specified index, so +1
 midPanels.addStyleName("horizontalPanelStyle");
 midIndex++;
}

if(result.get(0).getVrmf().equals(oldVersion)){
 oldPanels.insert(testTable1, oldIndex + 1); //insert adds element BEFORE specified index, so +1
 oldPanels.addStyleName("horizontalPanelStyle");
 oldIndex++;
}

}

};

and here is how my calls are dispatched:
if(testPortalSvcNew != null){
testPortalSvcNew.getTestResults(5, newestVersion, TestType.SMOKE, callback); testPortalSvcNew.getTestResults(5, newestVersion, TestType.BVTUNIX, callback); testPortalSvcNew.getTestResults(5, newestVersion, TestType.BVTWINDOWS, callback); }

Every refresh generates a potentially different horizontal display order of test types. Versions are grouped properly and separated vertically, but their horizontal ordering is screwy. I'm stumped!

A: 

You could try creating a new TestTable instance for each panel. Now you are adding the same instance to all three panels. I am not sure if this helps but this sometimes may cause strange behaviour in GWT so it is worth a try.

However I agree with @j flemm that you can never be sure in what order your asynchronous services will be executed.

Piotr
+4  A: 

So you're expecting the tests to come back in the order SMOKE, BVTUNIX then BVTWINDOWS?

If so, you're going to need to chain async calls or group them into one ajax call that returns all of them at once. Asynchronous calls are just that. There's no guarantee of return order.

j flemm
Just spoke to a coworker who's familiar with GWT, and he confirmed my fear as you have. I'll just pass the service an array of TestTypes and handle it that way. Thanks!I would +1 you if I had the reputation :-/I'm new to all of this :-)
xtremerunnerars