SmartGWT version: 3.0
Browser(s) version(s) involved:
- Google Chrome: 14.0.835.202 m
- Mozzila Firefox: v3.6.23
Hi,
I have a dataset of more than 2000 values (and this is one of the small ones I need to connect to) and I need to display them in a ListGrid. I have them in a list of objects, which contain fields: key & value (both Strings). I get these by doing an RPC call to my servlet from the client when I create my Datasoure and transform the objects to records and populate the Datasource. Here is my code:
public class CacheKeysDS extends DataSource
{
private AdminServletAsync adminService = (AdminServletAsync) GWT.create(AdminServlet.class);
public CacheKeysDS(String cacheName)
{
setClientOnly(true);
DataSourceTextField key = new DataSourceTextField("key",
"Key");
key.setPrimaryKey(true);
DataSourceTextField value = new DataSourceTextField("value",
"Value");
setFields(key, value);
loadData(cacheName);
}
private void loadData(final String cacheName)
{
AsyncCallback<List<CacheKeys>> callback = new AsyncCallback<List<CacheKeys>>() {
public void onFailure(Throwable caught) {
System.out.println("Problem getting data from server");
caught.printStackTrace();
}
public void onSuccess(List<CacheKeys> result) {
// Map Part-Entities to ListGridRecords
for (CacheKeys keys : result) {
addData(new CacheKeysLGR(keys.getKey(), keys.getValue()));
}
}
};
adminService.getCacheKeys(cacheName, callback);
}
}
I then call a fetch() command from my list grid and the data takes ages to load(more than 5mins) which is unacceptable.
Now I tried flushing the data as JSON on my servlet and created a Datasource with a DSDataFormat.JSON format that gets the values from there just to compare the speed. Data gets loaded here quite quickly 5-10sec.
The issue is I need to use the first approach because I need to push data from the server, which can be either a key's value has changed, a key has been added or a key has been deleted. I am doing this by using ICEPush and sending the objects to the client where I transform them in records and I perform correspondingly an updataData()/addData()/removeData() operation on the ListGrid. This works quite nice and is very fast.
I tried using the JSON approach, and when I had a push event I was creating a JSONObject from the object pushed from the server. Then I created a Record from the JSON object with the following code:
public class CacheKeysLGR extends ListGridRecord {
public CacheKeysLGR() {
}
public CacheKeysLGR(JSONValue key, JSONValue value){
setAttribute("key", key);
setAttribute("value", value);
}
}
Then I used the updataData()/addData()/removeData() operation on the ListGrid with the corresponding CacheKeysLGR record but the new data wasn’t picked up by my ListGrid.
So am I doing something wrong and why is the response time so slow? If it is an issue with the RPC is there a way I can do this by using JSON?
Thanks in advance!
Browser(s) version(s) involved:
- Google Chrome: 14.0.835.202 m
- Mozzila Firefox: v3.6.23
Hi,
I have a dataset of more than 2000 values (and this is one of the small ones I need to connect to) and I need to display them in a ListGrid. I have them in a list of objects, which contain fields: key & value (both Strings). I get these by doing an RPC call to my servlet from the client when I create my Datasoure and transform the objects to records and populate the Datasource. Here is my code:
public class CacheKeysDS extends DataSource
{
private AdminServletAsync adminService = (AdminServletAsync) GWT.create(AdminServlet.class);
public CacheKeysDS(String cacheName)
{
setClientOnly(true);
DataSourceTextField key = new DataSourceTextField("key",
"Key");
key.setPrimaryKey(true);
DataSourceTextField value = new DataSourceTextField("value",
"Value");
setFields(key, value);
loadData(cacheName);
}
private void loadData(final String cacheName)
{
AsyncCallback<List<CacheKeys>> callback = new AsyncCallback<List<CacheKeys>>() {
public void onFailure(Throwable caught) {
System.out.println("Problem getting data from server");
caught.printStackTrace();
}
public void onSuccess(List<CacheKeys> result) {
// Map Part-Entities to ListGridRecords
for (CacheKeys keys : result) {
addData(new CacheKeysLGR(keys.getKey(), keys.getValue()));
}
}
};
adminService.getCacheKeys(cacheName, callback);
}
}
I then call a fetch() command from my list grid and the data takes ages to load(more than 5mins) which is unacceptable.
Now I tried flushing the data as JSON on my servlet and created a Datasource with a DSDataFormat.JSON format that gets the values from there just to compare the speed. Data gets loaded here quite quickly 5-10sec.
The issue is I need to use the first approach because I need to push data from the server, which can be either a key's value has changed, a key has been added or a key has been deleted. I am doing this by using ICEPush and sending the objects to the client where I transform them in records and I perform correspondingly an updataData()/addData()/removeData() operation on the ListGrid. This works quite nice and is very fast.
I tried using the JSON approach, and when I had a push event I was creating a JSONObject from the object pushed from the server. Then I created a Record from the JSON object with the following code:
public class CacheKeysLGR extends ListGridRecord {
public CacheKeysLGR() {
}
public CacheKeysLGR(JSONValue key, JSONValue value){
setAttribute("key", key);
setAttribute("value", value);
}
}
Then I used the updataData()/addData()/removeData() operation on the ListGrid with the corresponding CacheKeysLGR record but the new data wasn’t picked up by my ListGrid.
So am I doing something wrong and why is the response time so slow? If it is an issue with the RPC is there a way I can do this by using JSON?
Thanks in advance!
Comment