nijogeorgep / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

AdvancedCriteria has problems with Date fields #497

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I try to save the value of an FilterBuilder. 
My approach is to retrieve the JSON data and save it as a String. This String 
will be saved in a DB later.
Everything works fine as long as I do not try to save and load Fields with a 
date value.

What steps will reproduce the problem?
1. create my Filter Builder:
 FilterBuilder filterBuilder1 = new FilterBuilder();     
2. To create the String with the filter data I use getCriteria()
String jsonFBvalue =(new 
JSONObject(filterBuilder1.getCriteria().getJsObj())).toString();

3. I created a new FilterBuilder and an AdvancedCriteria with the saved String 
in it. Then I loaded the AdvancedCriteria into filterbuilder2:
FilterBuilder filterBuilder = new FilterBuilder();  
AdvancedCriteria a= new AdvancedCriteria(JSON.decode(jsonFBvalue));
filterBuilder2.setCriteria(a);

What is the expected output? What do you see instead?
The expected result would be, that the filterBuilder2 shows the same filter 
values like filterBuilder1. 

But instead, if the saved value in String jsonFBvalue contains Date values, the 
FilterBuilder is only displaying field name and operator but no value. 

What version of the product are you using? On what operating system?
SmartGWT2.2, Firefox, Windows

Please provide any additional information below.

I think the problem occurs when I try to create the AdvancedCriteria with the 
String as data. The data in the the String looked ok: 
{"_constructor":"AdvancedCriteria", "operator":"and", 
"criteria":[{"fieldName":"LastUpdate", "operator":"equals", 
"value":1280872800000}]}

Best regards,

Arne

Original issue reported on code.google.com by arne.kor...@gmail.com on 16 Aug 2010 at 9:15

GoogleCodeExporter commented 8 years ago
I am sorry, I guess I had an error in my code. So this error report can be 
closed.
Creating the String the following way avoids the error described:

JSONEncoder settings = new JSONEncoder();
                settings.setDateFormat(JSONDateFormat.DATE_CONSTRUCTOR);                
String jsObj = JSON.encode(filterBuilder.getCriteria().getJsObj(), settings);

Original comment by arne.kor...@gmail.com on 16 Aug 2010 at 3:01

GoogleCodeExporter commented 8 years ago

Original comment by smartgwt...@gmail.com on 16 Aug 2010 at 3:06