So, I created a class called PageRequestHandler that will allow me to pass the page and size information for pagination that comes in to my Controller's URL, then access it in a lower layer to pass to my Spring Data Repository.
Here is the code.
https://gist.github.com/3718376
It is just missing storing Sort information to be 100% Spring Data supported.
Here is the code I would have in my Controller
Then in my Service, which is where I need to get it to pass to my Spring Data RepositoryCode:@RequestMapping("/search/{searchCriteria}/{page}/{size}") public @ResponseBody ListOfDomains<Event> searchEvents(@PathVariable("searchCriteria") String searchCriteria, @PathVariable("page") int page, @PathVariable("size") int size) { PageRequestHandler.setPageRequest(page, size); return eventService.searchEvents(searchCriteria); }
MarkCode:@Override public ListOfDomains<Event> findAllEventsByVisibility(EventVisibility visibility) { ListOfDomains<Event> events = new ListOfDomains<Event>( eventRepository.findByVisibility(visibility.name(), PageRequestHandler.getPageRequest()), EventDivsTitleAndRelationships.PUBLIC_EVENTS); return events; }


Reply With Quote