views:

429

answers:

1

My Application currently serves requests for data, and can order the data to the users requirements, using RequestParams

@RequestParam(value = "orderBy", required = false, defaultValue = "severity") String orderBy,
@RequestParam(value = "order", required = false, defaultValue = "desc") String order,

You get the idea.

However, I want to implement multi sorting, (ordering by severity, then matching severities are ordered by date). Code wise, this is easy (google-collections to the rescue), but how would I expose this to the user calling the service?

Ideally, I wouldn't want multiple orderBy @RequestParams (orderBy2, orderBy3, orderBy4) , as that's just plain ugly.

Thoughts?

Cheers

+2  A: 

Usually you should be able to just turn your request param into an array like:

@RequestParam(value = "orderBy", required = false, defaultValue = "severity") String[] orderBy,
@RequestParam(value = "order", required = false, defaultValue = "desc") String[] order,
Daff
Unreal, by no amount of Googling of reading the spring docs did I discover this. Thanks very much.
standard
I know, it is a little hidden. Sometimes it is just trial and error, but Spring really can do a lot of conversion magic
Daff