Hi, with SmartGwt 5, I can't find the correct JSON format return need by my ListGrid and her RestDataSource (only in case of multiple "add" in same operation/transaction).
The doc, explain a bad return, but I search one JSON correct response...
Previously i use correctly a XML datasource, but i didn't find the equivalent with JSON.
With XML correctly working, the result need to be :
But, with JSON, after differents tests, is not working something like :
It's a classic RestDataSource JSON.
Can you give me and to the documentation a working sample of JSON response with two operations in same transaction ?
For example, the client call :
Edit and SOLVED (reading this SmartGwt post):
The reply must be :
but you need use :
or configure servlet JSON return by adding default json*fix used by client.
The doc, explain a bad return, but I search one JSON correct response...
Previously i use correctly a XML datasource, but i didn't find the equivalent with JSON.
With XML correctly working, the result need to be :
Code:
<?xml version="1.0" encoding="UTF-8"?> <responses> <response> <data> <record> ... </record> </data> </response> <response> <data> <record> ... </record> </data> </response> <status>0</status> </responses>
Code:
{ "responses": { "status": 0, "response": [{ "response": { "status": 0, "data": { ... } } }, { "response": { "status": 0, "data": { ... } } }] } }
Code:
RestDataSource dataSource = new RestDataSource(); dataSource.setDataFormat(DSDataFormat.JSON); dataSource.setDataProtocol(DSProtocol.POSTMESSAGE); OperationBinding add = new OperationBinding(); add.setOperationType(DSOperationType.ADD); add.setDataProtocol(DSProtocol.POSTMESSAGE);
For example, the client call :
Code:
{ "transaction": { "transactionNum": 52, "operations": [{ "dataSource": "isc_sector_5_0", "operationType": "add", "textMatchStyle": "exact", "componentId": "UPStockOT58", "data": { "id": 1244962, "_selection_27": true }, "oldValues": null }, { "dataSource": "isc_sector_5_0", "operationType": "add", "textMatchStyle": "exact", "componentId": "UPStockOT58", "data": { "id": 1328573, "_selection_27": true }, "oldValues": null }] } }
Edit and SOLVED (reading this SmartGwt post):
The reply must be :
Code:
[{ "response": { "status": 0, "data": { ... } } }, { "response": { "status": 0, "data": { ... } } }]
Code:
dataSource.setJsonPrefix(""); dataSource.setJsonSuffix("");