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 に答える