PDA

View Full Version : Working with a trouble via Store.save()



Elia
26 Dec 2009, 9:54 AM
Hi, I got a trouble from store.save(). I have a grid with JsonStore, when I added one row in this grid then called store.save() to pass the change to JSP, I just got {"result":[{}]} . Please help me to check if I make some codding error.


A.js:

var QDRecord = Ext.data.Record.create([
{header: 'Q_Id', dataIndex: 'Q_Id'},
{header: 'Q_Revise', dataIndex: 'Q_Revise'},
{header: QD_Id', dataIndex: 'QD_Id'}
]);

var QD_proxy = new Ext.data.HttpProxy({
url: '../jsp/quotationDlist.jsp',
disableCaching : true,
api: {
create:{url: '../jsp/quotationD_save.jsp'},
read: {url: '../jsp/quotationDlist.jsp'},
update: {url: '../jsp/quotationD_save.jsp'},
destroy :{url: '../jsp/quotationD_remove.jsp'}
}

});

var QD_writer = new Ext.data.JsonWriter({
encode:false,
writeAllFields:true
});

var QD_reader = new Ext.data.JsonReader({
totalProperty: 'totalCount',
idProperty:'Q_Id',
root: 'result',
messageProperty: 'message'
},QDRecord);

var QD_store = new Ext.data.JsonStore({
proxy : QD_proxy,
root : 'result',
autoLoad : false,
totalProperty : 'totalCount',
remoteSort : true,
fields : QDRecord,
idProperty : 'QD_Id',
successProperty : 'success',
writer : QD_writer,
autoSave : false,
listeners : {
exception : function () {
console.info(arguments);
}
}
});

var QDcolumns = new Ext.grid.ColumnModel({
defaults: {
width: 70,
sortable: false
},
columns:[
{header: 'Q_Id', dataIndex: 'Q_Id',editor: new Ext.grid.GridEditor(new Ext.form.TextField())},
{header: 'Q_Revise', dataIndex: 'Q_Revise',editor: new Ext.grid.GridEditor(new Ext.form.TextField())},
{header: 'QD_Id', dataIndex: 'QD_Id',editor: new Ext.grid.GridEditor(new Ext.form.TextField())}
]});


var QDgrid = new Ext.grid.EditorGridPanel({
title: 'List',
region: 'center',
iconCls: 'icon-grid',
stripeRows : true,
frame: true,
store: QD_store,
cm: QDcolumns,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),

viewConfig: {
forceFit: true
},
tbar: [{
ref: '../addBtn',
iconCls: 'silk-add',
text: 'Add',
disabled: true,
handler: function(){
var u = new QDgrid.store.recordType({
Q_Id : '',
Q_Revise : '',
QD_Id : ''
});
QDgrid.stopEditing();
QDgrid.store.add(u);
QDgrid.startEditing(currGridRow,3);
}
},{
ref: '../removeBtn',
iconCls: 'silk-delete',
text: 'Delete',
disabled: true,
handler: function(){
Ext.Msg.confirm('Information','Are you sure that you want to permanently delete the selected?',function(btn){
if(btn == 'yes'){
QD_store.removeAt(currGridRow);
}
})
}
}],
buttons: [
{
text: 'Save',
iconCls: 'icon-save',
id: 'btnAllSave',
disabled: true,
listeners:{
click :function(b,e){
QD_store.save();
}
},
scope: QDgrid
}
]
});
quotationD_save.jsp


request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");


StringBuffer json = new StringBuffer();
String line = null;

BufferedReader reader = request.getReader();
int i =0;
while((line = reader.readLine()) != null) {
i++;
json.append(line);

}

System.out.println("json="+json.toString());
out.print("{success:true,msg:'OK'}");

I just got result in Tomcat console : json={"result":[{},{}]} .


Any help will be very appreciated.