0

I have a problem, which I cannot solve alone. So your help is very appreciated. Here we go: Always if I edit more than one row in my grid, I get a list of beans in my controller for further proceedings...e.g. save the changes, but if I edit only 1 row I get an empty list back or the list is null. It is only working if I edit more than 1 row.

Here is my store and proxy:

 var billRecordStore = null;
    function createbillRecordStore() {



var billRecordProxy = new Ext.data.HttpProxy({
            api : {
                read : applicationPath + '/filterRecords',
                update : applicationPath + '/updateRecords'
            },
            type : 'json',
            reader : {
                type : 'json',
                root : 'data',
                idProperty : 'brid',
                totalProperty : 'total'
            },
            writer : {
                type : 'json'
            },
            actionMethods: {
                create: 'POST', read: 'POST', update: 'POST', destroy: 'POST'
            },
            simpleSortMode: true
        });

        billRecordStore = Ext.create('Ext.data.Store', {
            pageSize : 25,
            model : 'billRecordModel',
            storeId : 'billRecordStore',
            proxy : billRecordProxy,
            remoteSort : false,
            autoLoad : false

        });
    }

That is my SpringMVC controller:

 @ResponseBody  
 @RequestMapping(value = "/updateRecords", method =
 {RequestMethod.POST, RequestMethod.GET}, produces =
 "application/json")    
 public ResponseWrapper updateBillrecord(
     @RequestBody List<BillRecordsDTO> dirtyBillRecords
 ) { 
     if (dirtyBillRecords != null && dirtyBillRecords.size() > 0)
     {
         billRecordService.updateBillRecords(dirtyBillRecords);
     }
  return null;  
 }

This list List<BillRecordsDTO> dirtyBillRecords is allways null if I am editing only 1 row in the grid. More than 1 edited row is working perfectly. I have no exception thrown at the server side. In the frontend I get only this exception in the chrome browser:

POST http://localhost:8080/servicetool/updateRecords?_dc=1384181576575 400 (Bad Request) ext-all-debug.js:32379
Ext.define.request ext-all-debug.js:32379
Ext.define.doRequest ext-all-debug.js:71730
Ext.define.update ext-all-debug.js:71455
Ext.define.runOperation ext-all-debug.js:74757
Ext.define.start ext-all-debug.js:74704
Ext.define.batch ext-all-debug.js:42884
Ext.define.sync ext-all-debug.js:43606
Ext.define.save ext-all-debug.js:43634
saveChanges billRecordController.js:113
Ext.create.items.tbar.handler serviceToolView.js:206
Ext.define.fireHandler ext-all-debug.js:46226
Ext.define.onClick ext-all-debug.js:46216
(anonymous function)
wrap

Any ideas? You need more information? Just tell me. Thank you very much in advance. edfred

F4k3d
  • 653
  • 1
  • 10
  • 29

1 Answers1

1

Check out the allowSingle config in the JSON Writer documentation.

By default, the JSON Writer will send single records as an object, while sending multiple records as an array. Setting allowSingle to false tells the writer to always wrap the request data in an array, regardless of the number of records being written.

EDIT: You should be able to see this in action by looking at the POST. In your current configuration, you should see a marked difference between the request sent for one record vs. a request sent for multiple records. Once you switch the allowSingle config to false, however, the requests should look quite a bit the same, except for the size of the array being sent.

existdissolve
  • 3,104
  • 1
  • 16
  • 12
  • Hi existdissolve. This was the solution. Thank you very much. It works now, perfectly. I changed the writer like that `...writer : {type : 'json', allowSingle : false}...` Have a nice day. – F4k3d Nov 12 '13 at 06:57