Announcement Announcement Module
Collapse
No announcement yet.
ThreadLocal Pagination to help keep layers api clean from pagination Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ThreadLocal Pagination to help keep layers api clean from pagination

    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

    Code:
    @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);
        }
    Then in my Service, which is where I need to get it to pass to my Spring Data Repository

    Code:
    @Override
        public ListOfDomains<Event> findAllEventsByVisibility(EventVisibility visibility) {
            ListOfDomains<Event> events = new ListOfDomains<Event>(
                    eventRepository.findByVisibility(visibility.name(),
                            PageRequestHandler.getPageRequest()),
                    EventDivsTitleAndRelationships.PUBLIC_EVENTS);
            return events;
        }
    Mark
    Last edited by bytor99999; Sep 13th, 2012, 07:07 PM.
Working...
X