I'm trying to get the XML serialized form of AdvancedCriteria in the same format as it is sent when it is used with RestDataSource.
Using
<artifactId>smartgwt-lgpl</artifactId>
<version>6.0-p20161211</version>
The above is sent to the server (using DSRequest) like
It does make sense and works consequently, by the way.
However, if I serialize it to XML by
It results
Please not that <criteria> is used instead of <criterion> and the containting <criteria> tag is missing.
Moreover, if I try to serialize something more complex like
Then I get
Which is not consistent with even itself: please note that at top level there are the two criterias of value 52100 and 52101 within <criteria> tags and without a containing element, while the nested "or" has the same expression but there are <elem> tags instead of <criteria> and there is a <criteria> element containing them outside.
Summarized:
ilab
Using
<artifactId>smartgwt-lgpl</artifactId>
<version>6.0-p20161211</version>
Code:
AdvancedCriteria crit1 = new AdvancedCriteria(OperatorId.OR, new AdvancedCriteria[] {
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52100"),
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52101"),
});
Code:
...
<data>
<_constructor>AdvancedCriteria</_constructor>
<criteria>
<criterion>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52100</value>
</criterion>
<criterion>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52101</value>
</criterion>
</criteria>
<operator>or</operator>
</data>
...
However, if I serialize it to XML by
Code:
RestDataSource q = new RestDataSource();
GWT.log(q.xmlSerialize(crit1.getJsObj()));
Code:
<isc_RestDataSource_0 _constructor="AdvancedCriteria"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<operator>or</operator>
<criteria>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52100</value>
</criteria>
<criteria>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52101</value>
</criteria>
</isc_RestDataSource_0>
Moreover, if I try to serialize something more complex like
Code:
AdvancedCriteria crit2 = new AdvancedCriteria(OperatorId.OR, new AdvancedCriteria[] {
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52100"),
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52101"),
new AdvancedCriteria(OperatorId.OR, new AdvancedCriteria[] {
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52100"),
new AdvancedCriteria("ec_ea_id", OperatorId.EQUALS, "52101"),
})
});
Code:
<isc_RestDataSource_0 _constructor="AdvancedCriteria"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<operator>or</operator>
<criteria>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52100</value>
</criteria>
<criteria>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52101</value>
</criteria>
<criteria>
<operator>or</operator>
<criteria>
<elem>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52100</value>
</elem>
<elem>
<fieldName>ec_ea_id</fieldName>
<operator>equals</operator>
<value>52101</value>
</elem>
</criteria>
</criteria>
</isc_RestDataSource_0>
Summarized:
- RestDataSource.xmlSerialize() seems to work inconsistently
- It would be nice to know how to achive the same serialized format as it is actually sent to the server.
ilab
Comment