I've seen lots of questions similar to mine but, I couldn't find a solution to this problem so far.
I am implementing a grid filtering and pagination on Spring + Hibernate. The load() method must receive the specific parameters for pagination (page, start and limit) and a list of key-value parameter for filtering, which is being the problem.
The parameters are coming like that:
page:1
start:0
limit:23
filter:[{"operator":"like","value":"tes","property":"desc"},{"operator":"like","value":"teste","property":"model_desc"}]
or (encoded version):
page=1&start=0&limit=23&filter=%5B%7B%22operator%22%3A%22like%22%2C%22value%22%3A%22tes%22%2C%22property%22%3A%22desc%22%7D%2C%7B%22operator%22%3A%22like%22%2C%22value%22%3A%22teste%22%2C%22property%22%3A%22model_desc%22%7D%5D
The filter parameter is coming as a String and the problem is to make Spring parse that either as something like ArrayList<Map<String,String>> or ArrayList<SomeFilterClass>.
This is the signature of my controller method (the commented lines are all not working, they are here just to show what I've tried so far):
public Map<String, Object> loadData(@RequestParam(value = "page", required = true) int page,
@RequestParam(value = "start", required = true) int start,
@RequestParam(value = "limit", required = true) int limit,
// @ModelAttribute("filter") ArrayList<Map<String, String>> filter) {
// @RequestParam(value = "filter", required = false) Map<String, Object>[] filter) {
// @RequestParam(value = "filter", required = false) List<Map<String, String>> filter) {
@ModelAttribute("filter") RemoteFilter filter)
This class, RemoteFilter, is a wrapper class that I built, following a suggestion from other posts but, it didn't work also. Its structure is:
public class RemoteFilter {
private ArrayList<Filter> filter;
//Getters and Setters....
class Filter {
private String operator;
private String value;
private String property;
//Getters and Setters....
}
}
I will be very glad if anybody help me with that.
Thanks!