Where is the solution about "how GSON works with generic collections"
I'm new to the thread. And I found pagullo in page 37 said, " if you take a look at how GSON works with generic collections, you'll find that there are other workarounds, but most of the time the solution I propose is easier." The thread is too long to browse, any friend know where the solution is?
My question is:
I have a a class like this:
Code:
public class DataStore<T> {
private int total;
private boolean success = true;
private List<T> data;
...//getters and setter
}
And I have a direct method like this:
Code:
@DirectMethod
public Object list(int start, int limit, String sort, String dir) {
List<User> users = this.users.subList(start, Math.min(start + limit, this.users.size() - 1));
return new DataStore<User>(users.size(), users, true);
}
When call this method by DirectStore, there is exception:
ExtJS version : Ext-4.0.7
DirectJNgine viersion: 2.0 alpha
How to solve the problem? Or there is something I'v ignore? Thanks.
DirectJNgine working with Gson
Hello pagullo?
I create a new Class extends the generic father class like this:
Code:
public class UserDataStore extends DataStore<User> {
public UserDataStore() {
}
public UserDataStore(int total, List<User> data) {
super(total, data);
}
public UserDataStore(int total, List<User> data, boolean success) {
super(total, data, success);
}
}
And the DirectMethod like this:
Code:
@DirectMethod
public UserDataStore list(int start, int limit, String sort, String dir) {
return new UserDataStore(users.size(), users, true); // users's type is "List<User>"
}
But It doesn't work.
And Web.xml is like this:
Code:
<servlet>
<servlet-name>DjnServlet</servlet-name>
<servlet-class>
com.softwarementors.extjs.djn.servlet.DirectJNgineServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>providersUrl</param-name>
<param-value>djn/directprovider</param-value>
</init-param>
<init-param>
<param-name>apis</param-name>
<param-value>fq</param-value>
</init-param>
<init-param>
<param-name>fq .apiFile</param-name>
<param-value>directapi/Api.js</param-value>
</init-param>
<init-param>
<param-name>fq.apiNamespace</param-name>
<param-value>Fq.api</param-value>
</init-param>
<init-param>
<param-name>fq.classes</param-name>
<param-value>dms.action.UsersAction, test.ActionTest </param-value>
</init-param>
<!--more parameters -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DjnServlet</servlet-name>
<url-pattern>/djn/directprovider/*</url-pattern>
</servlet-mapping>
BTW: I know gson can press a generic class perfectly, like:
Code:
DataStore<User> dataStore = new DataStore<User>(users.size(), users);
Type type = new TypeToken<DataStore<User>>() {}.getType();
Gson gson = new Gson();
String json = gson.toJson(dataStore, type);
Can we use this technique to meet the need? And I hope the DirectJNgine can process generic type rightly with gson, if not, there is a lot of unnecessary class will be written, this is not a good news.
When call two or more Direct Method continuously
Hello pagullo,
When I call two or more Direct Method continuously, such as:
Code:
UserAction.loadComplementaryRoles({userId : userId});
UserAction.loadSubordinativeRoles({userId : userId});
Normally, It will generate two requests, but actually, just one request was generated. This is the result from chrome15.
Quote:
Request Payload
[{"action":"UserAction","method":"loadComplementaryRoles","data"[{"userId":"2C9083443421D164013421D170E90005"}],"type":"rpc","tid":3}, {"action":"UserAction","method":"loadSubordinativeRoles","data"[{"userId":"2C9083443421D164013421D170E90005"}],"type":"rpc","tid":4}]
How to understand this? It has something to do with the "Action Scope"?
DirectJNgine - Spring Integration
Hello,
what about Spring Integration of DJN? Are there any plans to support it?
I found out about this project, which seems to be outdated... http://code.google.com/p/directjngine-spring/
This feature would be very helpful, as I need to register classes dynamically.