PDA

View Full Version : While Updating : Showing error like BAD REQUEST 400



kantha.exe
2 Jul 2012, 12:25 AM
Hi I am trying to update selected records in grid with check boxes the code as follows.....



var RoleMenuLinksStore = Ext.create('Ext.data.Store', {

extend: 'Ext.data.Store',
id: 'RoleMenuLinksStore',
model: 'RoleMenuLinks',

// proxy: roleMenuProxy

proxy:{

type: 'ajax',

api : {

read : 'RoleMenuLinksForChilds/view.action',
create:'RoleMenuLinks/update.action'

},
reader: {
type: 'json',
root: 'data',
idProperty: 'key',
successProperty : 'success',
messageProperty : 'message'
},
writer: {
type: 'json',
writeAllFields : true,
encode:false

}


}

});

and my grid loos as follows....
Ext.onReady(function() {





var roleKey=document.getElementById('roleKey');

var exportYN=document.getElementById('exportYN');
var addYN=document.getElementById('addYN');
var editYN=document.getElementById('editYN');
var viewYN=document.getElementById('viewYN');
var deleteYN=document.getElementById('deleteYN');
var menu=document.getElementById('menu');

var roleMenuLinkTitle=document.getElementById('roleMenuLinkTitle');


var sm = new Ext.selection.CheckboxModel({
listeners: {
selectionchange: function (selectionModel, selected, options) {

//selectionModel.view.refresh();
}
}
});



menuStore.on('load',function(store, records, options){

panelCount=store.getTotalCount();

//for(var i=0;i<panelCount;i++){



RoleMenuLinksStore1.load({
params:
{
menuID:1,
roleKey:roleKey.value
}
});

});



var grid = Ext.create('Ext.grid.Panel', {

xtype: 'grid',
// title: 'My Grid Panel',
id:'gridID',
store:RoleMenuLinksStore1,
selModel: sm,
columns: [

{
xtype: 'gridcolumn',
dataIndex: 'menu',
width: 200,
header: menu.value
},
{
xtype: 'checkcolumn',
dataIndex: 'addYN',
width: 100,
header:addYN.value

},
{
xtype: 'checkcolumn',
dataIndex: 'editYN',
width: 100,
header:editYN.value

},
{
xtype: 'checkcolumn',
dataIndex: 'deleteYN',
width: 100,

header: deleteYN.value
},
{
xtype: 'checkcolumn',
dataIndex: 'viewYN',
width: 100,
header:viewYN.value

},
{
xtype: 'checkcolumn',
dataIndex: 'exportYN',
width: 100,
header: exportYN.value
}
],
viewConfig: {


},
dockedItems: [
{
xtype: 'toolbar',
height: 31,
dock: 'top',
items: [
{
xtype: 'button',
text: 'Save/Update',
iconCls : 'icon-save',
handler:function(){

//saveAndUpdate();


var s=grid.getSelectionModel().getSelection();

alert(s.length);


if(s.length==0){

alert(" No Records Selecteds");
}else{

for(var i=0;i<s.length;i++){

var menuKey=s[i].get('menuKey');
var addYN=s[i].get('addYN')==true?'Y':'N';
var editYN=s[i].get('editYN')==true?'Y':'N';
var viewYN=s[i].get('viewYN')==true?'Y':'N';
var deleteYN=s[i].get('deleteYN')==true?'Y':'N';
var exportYN=s[i].get('exportYN')==true?'Y':'N';

alert(menuKey+addYN+editYN+viewYN+deleteYN+exportYN);

var record = Ext.create('RoleMenuLinks');

record.set({
roleKey:roleKey.value,
menuKey:menuKey,
addYN:addYN,
editYN:editYN,
viewYN:viewYN,
deleteYN:deleteYN,
exportYN:exportYN
});

alert("All Record Set ");

}

RoleMenuLinksStore.sync();

}

}
},
{
xtype: 'displayfield',
value: '',
fieldLabel: '',
width:250
},

{
xtype: 'button',
text: "Back",
iconCls : 'icon-previousnav',
handler : function() {

history.go(-1);

}
}
]
}
]


});
checkk('gridID',grid);
grid.render("roleMenuLink");

});



here is my code while updating record i am getting error like Bad Request 400 for my api....

and also its not calling controller .....
did anybody know why this is.....?:-?
36702

Izhaki
2 Jul 2012, 2:28 AM
Kantha,

Help others to help you buy putting your code within a
block, it is impossible to read your code at the moment.

404 means that the server request was referencing a file that doesn't exist. Your api includes: `RoleMenuLinksForChilds/view.action`, if you look at firebug / chrome developer tools you'll see what script exactly was called and you should see the the path is not the one you intended.

kantha.exe
2 Jul 2012, 3:24 AM
Oh Sorry for fault.....

ok will check ...

Thank You

friend
2 Jul 2012, 4:02 AM
A 400 Bad Request (http://www.checkupdown.com/status/E400.html) error means that the client browser's data stream is 'malformed' in some way. I get these kinds of errors if I don't send all request parameters which are expected by my server-side code.

kantha.exe
2 Jul 2012, 11:51 PM
ya I made mistake in JavaController
I used @RequestParam instead of @RequestBody now Working fine....:)



Thank You All....=D>