Frage

I'm using the Dojo datagrid client side, it works well and according to documentation it generates the following GET request when clicking on the column header:

GET http://localhost:8080/books/rest/books?sort(+isbn)

Problem is that I can't interpret the query parameter "sort(+isbn)" on the server side using the Apache Wink framework, because there's no value set for it. E.g. I'd expect something like "sort=+isbn" instead.

Here's my server side code:

@Path("/books")
public class BookServiceImpl implements BookService {
...
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String getBook(@QueryParam("sort") String sortBy) {
        System.out.println("Received Queryparam for sort is " + sortBy);
        return "";
    }

}

Since "sort(+isbn)" has no value assigned to it, it appears to be an invalid query parameter. Not sure why Dojo datagrid uses this convention.

Would appreciate help as to how to work around this on the Java side, ideally using Wink or another mechanism to process GET requests.

War es hilfreich?

Lösung

Try to use @Context UriInfo to get the full uri info, call to UriInfo.getQueryParameters to get all query params. I believe sort(+isbn) will be there.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top