ExtJS JsonStore 和 Netty
我试图在 ExtJS 和 Java 之间实现通信,我将请求从 ExtJS 发送到使用 netty 的 Java 服务器。如果有人能给我发送一个示例,说明如何从 java 端格式化响应以及如何从 ExtJS 端读取响应数据,我将不胜感激,提前致谢。 这是我来自 ExtJS 端的来源
var store = new Ext.data.JsonStore({
autoload: true,
baseParams: {
conid : '6b09477f-aa04-4f5a-b969-05277d01f07e'
},
root: 'OpenCashTime',
proxy: new Ext.data.ScriptTagProxy({
url: 'http://localhost:8080/getOpenCash?'
}),
fields: [{name: 'Time', mapping: 'Time', type: 'int'}]
});
store.load();
store.on('load', function() {
alert(store.getTotalCount());
});
store.on('write', function() {
alert(store.getTotalCount());
});
store.on('loadexception', function() {
alert("AAAAAA");
});
store.on('metachange', function() {
//alert(store.getTotalCount());
});
store.on('update', function() {
//alert(store.getTotalCount());
});
store.on('save', function() {
//alert(store.getTotalCount());
});
store.on('datachanged', function() {
//alert(store.getTotalCount());
});
当执行此代码并接收此响应 {"OpenCashTime":[{"Time":1291623637000},{"Time":1294914317000}]} 我仍然得到一个 loadException 尽管即使 firebug 也看到了它的 Json
Im trying to impelement comunication between ExtJS and Java I'm sending requests from ExtJS to a Java server thats using netty. I would appriciate if someone could send me an example of how the response should be formated from the java side and how to read the response data from the ExtJS side thanks in advance.
This is my source from the ExtJS side
var store = new Ext.data.JsonStore({
autoload: true,
baseParams: {
conid : '6b09477f-aa04-4f5a-b969-05277d01f07e'
},
root: 'OpenCashTime',
proxy: new Ext.data.ScriptTagProxy({
url: 'http://localhost:8080/getOpenCash?'
}),
fields: [{name: 'Time', mapping: 'Time', type: 'int'}]
});
store.load();
store.on('load', function() {
alert(store.getTotalCount());
});
store.on('write', function() {
alert(store.getTotalCount());
});
store.on('loadexception', function() {
alert("AAAAAA");
});
store.on('metachange', function() {
//alert(store.getTotalCount());
});
store.on('update', function() {
//alert(store.getTotalCount());
});
store.on('save', function() {
//alert(store.getTotalCount());
});
store.on('datachanged', function() {
//alert(store.getTotalCount());
});
When executing this code and reciving this response {"OpenCashTime":[{"Time":1291623637000},{"Time":1294914317000}]} I still get a loadexception although even firebug sees its Json
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的标题,假设您想要将数据加载到 JsonStore 中,它需要一个有效的 Json 字符串,并具有存储 JSON 对象数组的属性,该属性将作为记录加载。属性名称是在配置 JsonStore 时通过
root
属性设置的。像这样存储:
很乐意吃这样的东西:
Assuming from your title, that you want to load data into JsonStore, it expects a valid Json string, with a property storing an array of JSON objects, that will be loaded as records. The property name is set up by
root
property when configuring JsonStore.Store like this:
Will gladly eat something like this:
顺便说一句,在身份映射的情况下,您可以将其省略。这两个案例会给你
相同的结果。
BTW In the case of an identity mapping you can leave it out. These two cases will give you
the same results.