SmartGwt ver. 3.0
Jetty 8.2
Java 1.6
gwt 2.4
I'm not sure what the problem is but for some reason when I need to get an array of Records from an underline json message it would not work when running in prod mode. When app is deployed on server as a war it does not work but when running in dev mode in eclipse it works fine. This is very strange my entire app works fine but this case seems to work differently.
Record.convertToRecordArray does not return a fully populated Record [] even though I know it is an array. I found the root problem, when you call JSOHelper.isArray its value is false. However when I construct a json array object using google api i get a JSONArray object. The really wacky part is if I dont call isArray() and just construct my array using JSOHelper.toArray() the array of Records is created without problem.
The following code is my sample that shows the difference in array checking
****
String json = "[{\"first\":\"Dennis\", \"last\":\"Smith\"}]";
JSONValue value = JSONParser.parseStrict(json);
final JSONArray arry = value.isArray();
if(arry != null){
Log.info("JSONArray.isArray() : true ");
}
else{
Log.info("JSONArray.isArray() : false ");
}
if (JSOHelper.isArray(arry.getJavaScriptObject())) {
Log.info("JSOHelper.isArray() : true ");
}
else{
Log.info("JSOHelper.isArray() : false ");
}
****
Results:
Running in Eclipse dev mode
JSONArray.isArray() : true
JSOHelper.isArray() : true
Running on Jetty as a war
JSONArray.isArray() : true
JSOHelper.isArray() : false
Jetty 8.2
Java 1.6
gwt 2.4
I'm not sure what the problem is but for some reason when I need to get an array of Records from an underline json message it would not work when running in prod mode. When app is deployed on server as a war it does not work but when running in dev mode in eclipse it works fine. This is very strange my entire app works fine but this case seems to work differently.
Record.convertToRecordArray does not return a fully populated Record [] even though I know it is an array. I found the root problem, when you call JSOHelper.isArray its value is false. However when I construct a json array object using google api i get a JSONArray object. The really wacky part is if I dont call isArray() and just construct my array using JSOHelper.toArray() the array of Records is created without problem.
The following code is my sample that shows the difference in array checking
****
String json = "[{\"first\":\"Dennis\", \"last\":\"Smith\"}]";
JSONValue value = JSONParser.parseStrict(json);
final JSONArray arry = value.isArray();
if(arry != null){
Log.info("JSONArray.isArray() : true ");
}
else{
Log.info("JSONArray.isArray() : false ");
}
if (JSOHelper.isArray(arry.getJavaScriptObject())) {
Log.info("JSOHelper.isArray() : true ");
}
else{
Log.info("JSOHelper.isArray() : false ");
}
****
Results:
Running in Eclipse dev mode
JSONArray.isArray() : true
JSOHelper.isArray() : true
Running on Jetty as a war
JSONArray.isArray() : true
JSOHelper.isArray() : false