Here is one learning which helped us overcome Adobe AIR screen freeze in production.
One of our products uses Adobe Flex – AIR for a desktop client and talks to a Java server.
We had to populate a datagrid in AIR.
We used XMLList collection of AS3(ActionScript) to populate the datagrid with the values sent from the server. It was all hunky dory when the data sent back was small.
Here is an example of client code to display the datagrid:
[This is just a sample. logDGModel is the XMLList collection.]
To send requests to the servlet from AS3, we used Httpservice API.
<In the Servlet>
We used XStream API to wrap the data and send it back to the client.
As the data started growing, the Flex datagrid started to freeze while displaying the data.
<‘Enter the JSON’>
Felt that XML with its heavyweight structure is slowing down the datagrid rendering during the parse. So thought of using JSON.
Now lets see how we can use JSON at the client and the server :-
At Flex Client:
Just import com.adobe.serialization.json.JSON;
Once the response comes back, from the result event, get the data,
var arr:Array = (com.adobe.serialization.json.JSON.decode(e.result) as Array);
var dp:ArrayCollection = new ArrayCollection(arr);
// Populate the dataprovider
Application.application.logDG.dataProvider = dp;
At the Servlet, format JSON Response and send it back:
Here we can pass an ArrayList of String or list of any custom Java objects.
// Call the service layer and get the data
List<Employee> employees = employeeService.getEmployees();
It worked nicely and is able to handle huge data.
The whole thing started flowing like a river!