【发布时间】:2015-09-08 03:47:11
【问题描述】:
我正在将我们的 Extjs 4.2 应用程序升级到 Extjs 5.0。
我能够调出所有只读页面,但是当我尝试更新/保存数据时遇到问题。非常感谢您的帮助!
我的模型数据值没有显示在服务器端,我可以使用 console.log(model) 打印模型并且它具有所有值,但在服务器端它只有id 和所有其他参数都显示为 null。
这是模型中的代理:
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
id: 'user',
proxy: {
type: 'rest',
url : '/rest/update/user',
listeners: {
exception: function(proxy, response, operation) {
Ext.Msg.alert('Failed', 'Save the user Failed!');
}
}
},
fields: [
{name: 'id', type: 'int'},
{name: 'userName', type: 'string'},
{name: 'country', type: 'string'}
]
}
控制器:
onUserUpdateAction: function(button, event, action) {
var model = Ext.create('MyApp.model.User');
model.set('id', "123");
model.set('userName', "john");
model.set('country', "usa");
---
model.commit() / without commit() it does not add the id in URL like /user/123
model.save();
}
这是服务器端代码:
@PUT
@Consumes({ "application/json" })
@Path("/Update/user/{id}")
updateUser(@PathParam("id") final int id, final User record);
实现类的第一行日志,有id但是其他的都是null
*** In updateUser() method, id : 123, record: User(id=123, **userName=null, country=null**)
【问题讨论】:
标签: javascript extjs4 extjs5