PDA

View Full Version : Error 400 on call store.add(record)



georgesq
21 Aug 2012, 2:28 PM
I will trying integrate my app with spring mvc 3, but i´m receiving error 400... below my codes:

Ext.define("DevInCachu.store.Users", {
extend: "Ext.data.Store",


config: {
model: "DevInCachu.model.User",
autoSave: false,
proxy: {
type: 'ajax',
api: {
read : 'user/view.action',
create : 'user/create.action',
update: 'user/create.action',
destroy: 'user/delete.action'
},
writer: {
type: 'json',
enconde: false,
writeAllFields: true
}
}
}
});

partial code of my controller:

authenticateUser: function () {


var authenticateForm = this.getAuthenticateForm();


var currentAuth = authenticateForm.getRecord();
var newValues = authenticateForm.getValues();


currentAuth.set("name", newValues.name);
currentAuth.set("password", newValues.password);


var errors = currentAuth.validate();


if (!errors.isValid()) {
Ext.Msg.alert('Error!', errors.getByField("name")[0].getMessage(), Ext.emptyFn);
currentContato.reject();
return;
}


var usersStore = Ext.getStore("Users");


if (null == usersStore.findRecord('id', currentAuth.data.id)) {
usersStore.add(currentAuth);
}


usersStore.sync();


//this.ativarListaContatos();
}

My java controller:
@RequestMapping(value = "/user/create.action")
public @ResponseBody Map<String, ? extends Object> create(@RequestParam Object data) {
try {
@SuppressWarnings("unchecked")
List<User> contacts = Collections.EMPTY_LIST;


return getMap(contacts);


} catch (Exception e) {
return getModelMapError("Error trying to create contact.");
}
}
Tks for any help.
George

mitchellsimoens
23 Aug 2012, 4:33 AM
This is an error in your backend that it's not handling the data properly. This isn't a Sencha Touch issue.

georgesq
23 Aug 2012, 4:46 AM
My proxy didn´t have a writer and the parameter name was different from server param.

Tks
George