Thursday, January 23, 2014

problem with asynchronous call

I have a problem with RPC call in GWT. I am a beginner. can any one help me to solve this.

below is an example code snippet:

I have four columns in my UI with effdate and enddate as column header.
The values are not displaying in order. The first column value is displaying in 3rd column.
most of the time the order changes.Displaying randomly.

I guess the RPC call to the service method for each count is delayed.
and I found out by debugging the effdate and end date that i am passing for first loop is executing 2nd or 3rd sometimes. It is shuffling.

Can anyone tellme what changes i need to do in my code to get correct values displayed in UI.

count=4;
List finalList = new arrayList();
for(i=0;i<count;count++)
{
effdate= list.get(countincr);
enddate= list.get(countincr+1);
//call to service to fetch values from DB by passing effdate and end date as parameter.
grp.ratecalc(startdate,enddate,new AsyncCallback<List<grVo>>()
{
public void onfailure(throwable caught)
{
sys.out.print("failure");
}
public void onsuccess(List<grVo> result)
{
List grpList= new GrpVO();

rate = result.get(0).getrate();
rate1 = result.get(0).getrate1();

grpList.setrate();
grpList.setrate1();

setting values in bean for  the remaining values in the result.

finalList.add(grpList);


if(finalList.size()== count)
{
//calling a method to populate the values
 methoddisplay(finalList);

}
}
}
);
countincr+=2;

}  //end of for loop

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment