2011-08-19 90 views
0

我使用extdirectspring爲我的Spring MVC應用程序設置了分機直接。我能夠檢索原語和字符串並在ext.js中使用它們。當我嘗試檢索對象列表時,我在javascript端獲得「未定義」。有什麼特別的,我需要做的人類課程,讓它的工作?extdirectspring方法不起作用

我註釋下面的代碼:

@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" 
}; 
+0

我需要看到HTML和JS。你必須在春天做一個鏈接到自動生成的js。 – chrislovecnm

+0

這裏是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」};' –

+0

正如我所提到的,我需要看到html和js – chrislovecnm

回答

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();