extdirectspring methods not working

1.1k Views Asked by At

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

There are 1 best solutions below

0
On

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