@RequestMapping( value = {"/", "/index", ""}, method = RequestMethod.GET) public String list(ModelMap model) { _SearchDTO searchCriteria = new _SearchDTO(); searchCriteria.setPage(0); searchCriteria.setPageSize(5); List<Client> orgs = clientService.findAll(searchCriteria); model.addAttribute(MODEL_ATTRIBUTES, orgs); model.addAttribute(SEARCH_CRITERIA, searchCriteria); List<Integer> pages = new ArrayList<>(); for (int i = 0; i < searchCriteria.getTotalPages(); i++) { pages.add(i); } model.addAttribute("pages", pages); return LIST_VIEW; }
@RequestMapping( value = {"/", "/index", ""}, method = RequestMethod.POST) public String search(@ModelAttribute(SEARCH_CRITERIA) _SearchDTO searchCriteria, ModelMap model) { String searchTerm = searchCriteria.getSearchTerm(); List<Client> orgs; if (searchTerm != null && !searchTerm.trim().isEmpty()) { orgs = clientService.search(searchCriteria); } else { orgs = clientService.findAll(searchCriteria); } model.addAttribute(MODEL_ATTRIBUTES, orgs); model.addAttribute(SEARCH_CRITERIA, searchCriteria); List<Integer> pages = new ArrayList<>(); for (int i = 0; i < searchCriteria.getTotalPages(); i++) { pages.add(i); } model.addAttribute("pages", pages); return LIST_VIEW; }