extdirectspring 方法不起作用

发布于 2024-11-30 15:36:44 字数 892 浏览 3 评论 0原文

我使用 extdirectspring 为我的 Spring MVC 应用程序设置了 ext direct。我能够检索基元和字符串并在 ext.js 中使用它们。当我尝试检索对象列表时,我在 javascript 方面得到“未定义”。我需要对 Person 类做些什么特殊的事情才能让它工作吗?

我注释了以下代码:

@ExtDirectMethod(ExtDirectMethodType.STORE_READ)
@Override
public Collection<Person> getPeople(String groupId) {

    Group group = GroupManager.getGroup(groupId);
    return group.getPeopleList(); 
}

这是我在客户端使用的代码:

directory.getPeople(id, function(result) {
    console.log(result);
});

这是 app.js 的样子:

Ext.ns('Ext.app');
Ext.app.REMOTING_API = {
    "actions":{
        "directory":[{
            "name":"getID","len":0
        },{
            "name":"getPeople","len":1
        }
    ]}‌​,
    "type":"remoting",
    "url":"/test/action/router"
};

I set up ext direct for my Spring MVC app using extdirectspring. I am able to retrieve primitives and Strings and use them in ext.js. When I try to retrieve a list of objects, I am getting "undefined" on the javascript side. Is there anything special that I need to do to the Person class to get it to work?

I annotated the following code:

@ExtDirectMethod(ExtDirectMethodType.STORE_READ)
@Override
public Collection<Person> getPeople(String groupId) {

    Group group = GroupManager.getGroup(groupId);
    return group.getPeopleList(); 
}

This is what I am using on the client side:

directory.getPeople(id, function(result) {
    console.log(result);
});

Here is what app.js looks like:

Ext.ns('Ext.app');
Ext.app.REMOTING_API = {
    "actions":{
        "directory":[{
            "name":"getID","len":0
        },{
            "name":"getPeople","len":1
        }
    ]}‌​,
    "type":"remoting",
    "url":"/test/action/router"
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2024-12-07 15:36:44

您是否尝试过使用 ExtDirectStoreResponse 类?它确实使用集合,但也管理一些在商店中使用的有用值。

@ExtDirectMethod(ExtDirectMethodType.STORE_READ)
public ExtDirectStoreResponse<Person> load()
{
    Group group = GroupManager.getGroup(groupId);
    Collection<Person> people = group.getPeopleList();

    return new ExtDirectStoreResponse<Person>(people.size(), people);
}

这是使用 STORE_READ 时使用的方法。该方法注释期望请求与 ExtDirectStoreReadRequest 类中的值匹配。这是进行存储读取时使用的参考。 https://github.com/ralscha/extdirectspring/wiki/Store-Read-Method

另外,您可以设置一个 ExtJs 存储并调用,而不是直接调用该方法

store.load();

Have you tried using the ExtDirectStoreResponse class? It does use a collection but also manages some useful values for use in the store.

@ExtDirectMethod(ExtDirectMethodType.STORE_READ)
public ExtDirectStoreResponse<Person> load()
{
    Group group = GroupManager.getGroup(groupId);
    Collection<Person> people = group.getPeopleList();

    return new ExtDirectStoreResponse<Person>(people.size(), people);
}

This is the approach to use when using the STORE_READ. That method annotation is expecting the request to come in matching values in the ExtDirectStoreReadRequest class. This is the reference to use when doing a store read. https://github.com/ralscha/extdirectspring/wiki/Store-Read-Method

Also, instead of calling the method directly, you would set up an ExtJs store and call

store.load();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文