@Autowired
private RuleReferentialService ruleReferentialService;
@RequestMapping(value = BoUrls.RULE_LIST_URL, method = RequestMethod.GET)
public ModelAndView ruleList(final HttpServletRequest request, final Model model) throws Exception {
ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), BoUrls.RULE_LIST.getVelocityPage());
final RequestData requestData = requestUtil.getRequestData(request);
String url = request.getRequestURI();
String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
String sessionKey = "PagedListHolder_Rules";
PagedListHolder<RuleViewBean> ruleViewBeanPagedListHolder = new PagedListHolder<RuleViewBean>();
if(StringUtils.isEmpty(page)){
ruleViewBeanPagedListHolder = initList(request, sessionKey);
} else {
ruleViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
if (ruleViewBeanPagedListHolder == null) {
ruleViewBeanPagedListHolder = initList(request, sessionKey);
}
int pageTarget = new Integer(page).intValue() - 1;
int pageCurrent = ruleViewBeanPagedListHolder.getPage();
if (pageCurrent < pageTarget) {
for (int i = pageCurrent; i < pageTarget; i++) {
ruleViewBeanPagedListHolder.nextPage();
}
} else if (pageCurrent > pageTarget) {
for (int i = pageTarget; i < pageCurrent; i++) {
ruleViewBeanPagedListHolder.previousPage();
}
}
}
modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, ruleViewBeanPagedListHolder);
return modelAndView;
}