Reputation: 55
I´m working showing some info on a table and I´m using @PageableDefault(size = Constants.PAGE_SIZE) Pageable pageable
to determine the size of the page im showing(5 elements at the moment).
The point here is that I want to be able to change the value of that page size using a <select>
to be able to modify the page size in my controller and redirect it into my table endpoint:
@PostMapping("/size")
public String size(){
//Constants.PAGE_SIZE;
return "redirect:/users/showusers";
}
Any help will be appreciated.
Upvotes: 2
Views: 6605
Reputation: 6254
You can pass page request like this, pass your size variable in page request.
PageRequest pageRequest = PageRequest.of(0, 5); //or default
use below to pass page size dynamically..
PageRequest pageRequest = PageRequest.of(0, size);
in repository method pass Pageable pageable
Upvotes: 3