0

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 服务方法?

4

1 回答 1

0

我对旧商店/dojox 网格的经验很少,但如果您使用的是 dojo/store/JsonRest:您可以更改它发送排序参数的方式sortParam。无耻地从参考指南中摘录:

var store = new JsonRest({
  target: "/FooObject/",
  sortParam: "sortBy"
});

这应该在表单上提出请求/foo/bar?sortBy=+id

http://dojotoolkit.org/reference-guide/1.8/dojo/store/JsonRest.html#sorting

于 2012-12-12T21:03:12.443 回答