Dojo 网格通过向 REST Web 服务发出请求来实现排序,如下所示:
GET http://server/request?sort(+id)
sort(+id)
方向 (+/-) 和要排序的列在哪里。
目前我正在这样做,它可以工作,但它很难看:
@GET
@Path("request/")
@Produces(MediaType.APPLICATION_JSON)
public Collection<RequestDataWithCurrentStatus> getAllRequests() {
Collection<RequestDataWithCurrentStatus> col = new ArrayList<RequestDataWithCurrentStatus>();
....
//handle the various types of sorting that can be requested by the dojo widget
String queryString = this.request.getQueryString();
//parse the dojo sort string 'sort(+id)' and sort
...
return col;
}
此方法使用注入的 RESTEasy@Context private HttpServletRequest request
来访问原始查询字符串。
我觉得我应该能够在我的调用中将此查询字符串映射到 RESTEasy 的@*Param
注释之一。getAllRequests()
但是根据 RESTEasy 的文档,似乎没有一个很好的映射到文档中的螺旋 dojo 查询字符串。我想做这样的事情:
@GET
@Path("request/")
@Produces(MediaType.APPLICATION_JSON)
public Collection<RequestDataWithCurrentStatus> getAllRequests( @DojoQueryParam String sort) {
...
}
如何以正确的方式将 dojo 网格查询字符串编组为 RESTEasy Web 服务方法?