Extdirectspring方法不起作用



我使用extdirectspring为我的Spring MVC应用程序设置了extdirect。我能够检索原语和字符串,并在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"
};

您是否尝试过使用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时使用的方法。该方法注释期望请求在extdirectstoreereadrequest类中匹配值。这是在执行存储读取操作时使用的引用。https://github.com/ralscha/extdirectspring/wiki/Store-Read-Method

另外,您可以设置一个ExtJs存储并调用

,而不是直接调用该方法
store.load();

最新更新