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.