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
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