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"
};
4

1 回答 1

1

您是否尝试过使用 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();
于 2013-09-11T16:17:08.330 回答