Example usage for org.springframework.beans.support PagedListHolder previousPage

List of usage examples for org.springframework.beans.support PagedListHolder previousPage

Introduction

In this page you can find the example usage for org.springframework.beans.support PagedListHolder previousPage.

Prototype

public void previousPage() 

Source Link

Document

Switch to previous page.

Usage

From source file:org.openmrs.module.conceptsearch.web.controller.AbstractSearchFormController.java

public void switchToPage(@RequestParam("page") String page, ModelMap model, WebRequest request,
        HttpSession session) {//from   w  w  w .  java  2  s  .c o m

    PagedListHolder resListHolder = (PagedListHolder) session.getAttribute("sortResults");
    if (resListHolder != null) {
        if ("previous".equals(page)) {
            resListHolder.previousPage();
        } else if ("next".equals(page)) {
            resListHolder.nextPage();
        } else {
            resListHolder.setPage(Integer.parseInt(page));
        }
        model.addAttribute("searchResult", resListHolder);
    } else {
        log.warn("Results are gone");
    }
}

From source file:fr.hoteia.qalingo.web.mvc.controller.rule.RuleController.java

@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.getVelocityPage());

    final String contentText = getSpecificMessage(ScopeWebMessage.RULE, BoMessageKey.MAIN_CONTENT_TEXT,
            getCurrentLocale(request));/*w ww  .j a v  a 2  s . c  om*/
    modelAndView.addObject(ModelConstants.CONTENT_TEXT, contentText);

    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;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.order.OrderController.java

@RequestMapping(value = BoUrls.ORDER_LIST_URL, method = RequestMethod.GET)
public ModelAndView orderList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoUrls.ORDER.getVelocityPage());

    final String contentText = getSpecificMessage(ScopeWebMessage.ORDER, BoMessageKey.MAIN_CONTENT_TEXT,
            getCurrentLocale(request));/*w ww. j a  v  a 2 s. c  om*/
    modelAndView.addObject(ModelConstants.CONTENT_TEXT, contentText);

    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    String sessionKey = "PagedListHolder_Orders";

    PagedListHolder<OrderViewBean> orderViewBeanPagedListHolder = new PagedListHolder<OrderViewBean>();

    if (StringUtils.isEmpty(page)) {
        orderViewBeanPagedListHolder = initList(request, sessionKey);

    } else {
        orderViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (orderViewBeanPagedListHolder == null) {
            orderViewBeanPagedListHolder = initList(request, sessionKey);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = orderViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                orderViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                orderViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, orderViewBeanPagedListHolder);

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.shipping.ShippingController.java

@RequestMapping(value = BoUrls.SHIPPING_LIST_URL, method = RequestMethod.GET)
public ModelAndView shippingList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoUrls.SHIPPING.getVelocityPage());

    final String contentText = getSpecificMessage(ScopeWebMessage.SHIPPING, BoMessageKey.MAIN_CONTENT_TEXT,
            getCurrentLocale(request));//from   w ww .ja  v a  2  s . c om
    modelAndView.addObject(ModelConstants.CONTENT_TEXT, contentText);

    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    String sessionKey = "PagedListHolder_Shippings";

    PagedListHolder<ShippingViewBean> shippingViewBeanPagedListHolder = new PagedListHolder<ShippingViewBean>();

    if (StringUtils.isEmpty(page)) {
        shippingViewBeanPagedListHolder = initList(request, sessionKey);

    } else {
        shippingViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (shippingViewBeanPagedListHolder == null) {
            shippingViewBeanPagedListHolder = initList(request, sessionKey);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = shippingViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                shippingViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                shippingViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, shippingViewBeanPagedListHolder);

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.customer.CustomerController.java

@RequestMapping(value = "/customer-list.html*", method = RequestMethod.GET)
public ModelAndView customerList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoPageConstants.CUSTOMER_LIST_VELOCITY_PAGE);

    final String contentText = getSpecificMessage(ScopeWebMessage.CUSTOMER, BoMessageKey.MAIN_CONTENT_TEXT,
            getCurrentLocale(request));/* w  w  w  .  j a  va  2s  . com*/
    modelAndView.addObject(ModelConstants.CONTENT_TEXT, contentText);

    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    String sessionKey = "PagedListHolder_Customers";

    PagedListHolder<CustomerViewBean> customerViewBeanPagedListHolder = new PagedListHolder<CustomerViewBean>();

    if (StringUtils.isEmpty(page)) {
        customerViewBeanPagedListHolder = initList(request, sessionKey);

    } else {
        customerViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (customerViewBeanPagedListHolder == null) {
            customerViewBeanPagedListHolder = initList(request, sessionKey);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = customerViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                customerViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                customerViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, customerViewBeanPagedListHolder);

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.customer.CustomerOrderController.java

@RequestMapping(FoUrls.PERSONAL_ORDER_LIST_URL)
public ModelAndView customerWishList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            FoUrls.PERSONAL_ORDER_LIST.getVelocityPage());

    final Customer customer = requestUtil.getCurrentCustomer(request);

    List<Order> orders = orderService.findOrdersByCustomerId(customer.getId().toString());
    if (orders != null && orders.size() > 0) {
        String url = requestUtil.getCurrentRequestUrl(request);

        String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
        String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
        PagedListHolder<OrderViewBean> orderViewBeanPagedListHolder;

        if (StringUtils.isEmpty(page)) {
            orderViewBeanPagedListHolder = initList(request, sessionKey, orders,
                    new PagedListHolder<OrderViewBean>());
        } else {//from   w  ww .j  av  a2s  . com
            orderViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
            if (orderViewBeanPagedListHolder == null) {
                orderViewBeanPagedListHolder = initList(request, sessionKey, orders,
                        orderViewBeanPagedListHolder);
            }
            int pageTarget = new Integer(page).intValue() - 1;
            int pageCurrent = orderViewBeanPagedListHolder.getPage();
            if (pageCurrent < pageTarget) {
                for (int i = pageCurrent; i < pageTarget; i++) {
                    orderViewBeanPagedListHolder.nextPage();
                }
            } else if (pageCurrent > pageTarget) {
                for (int i = pageTarget; i < pageCurrent; i++) {
                    orderViewBeanPagedListHolder.previousPage();
                }
            }
        }
        model.addAttribute(Constants.PAGINATION_PAGE_URL, url);
        model.addAttribute(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, orderViewBeanPagedListHolder);
    }

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.search.SearchController.java

@RequestMapping(value = FoUrls.SEARCH_URL, method = RequestMethod.POST)
public ModelAndView search(final HttpServletRequest request, final HttpServletResponse response,
        @Valid SearchForm searchForm, BindingResult result, ModelMap modelMap) throws Exception {

    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            FoUrls.SEARCH.getVelocityPage());

    if (result.hasErrors()) {
        return displaySearch(request, response, modelMap);
    }//from w ww. j  ava 2 s .c om

    final SearchViewBean search = viewBeanFactory.buildSearchViewBean(requestUtil.getRequestData(request));
    modelAndView.addObject("search", search);

    try {
        ProductResponseBean productResponseBean = productSolrService.searchProduct();
        modelAndView.addObject(Constants.SEARCH_FACET_FIELD_LIST, viewBeanFactory
                .buildSearchFacetViewBeans(requestUtil.getRequestData(request), productResponseBean));

        String url = requestUtil.getCurrentRequestUrl(request);

        String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
        String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
        PagedListHolder<SearchProductItemViewBean> accountsViewBeanPagedListHolder;

        if (StringUtils.isEmpty(page)) {
            accountsViewBeanPagedListHolder = initList(request, sessionKey, productResponseBean,
                    new PagedListHolder<SearchProductItemViewBean>());
        } else {

            accountsViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
            if (accountsViewBeanPagedListHolder == null) {
                accountsViewBeanPagedListHolder = initList(request, sessionKey, productResponseBean,
                        accountsViewBeanPagedListHolder);
            }
            int pageTarget = new Integer(page).intValue() - 1;
            int pageCurrent = accountsViewBeanPagedListHolder.getPage();
            if (pageCurrent < pageTarget) {
                for (int i = pageCurrent; i < pageTarget; i++) {
                    accountsViewBeanPagedListHolder.nextPage();
                }
            } else if (pageCurrent > pageTarget) {
                for (int i = pageTarget; i < pageCurrent; i++) {
                    accountsViewBeanPagedListHolder.previousPage();
                }
            }
        }
        modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
        modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, accountsViewBeanPagedListHolder);

    } catch (Exception e) {
        LOG.error("SOLR Error", e);
    }

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.user.UserController.java

@RequestMapping(value = BoUrls.USER_SEARCH_URL, method = RequestMethod.GET)
public ModelAndView userList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoUrls.USER_LIST.getVelocityPage());

    final Localization currentLocalization = requestUtil.getCurrentLocalization(request);
    final Locale locale = currentLocalization.getLocale();
    initLinks(request, modelAndView, locale, null);

    List<User> users = userService.findUsers();

    String url = requestUtil.getCurrentRequestUrl(request);

    String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    PagedListHolder<UserViewBean> userViewBeanPagedListHolder;

    if (StringUtils.isEmpty(page)) {
        userViewBeanPagedListHolder = initList(request, sessionKey, currentLocalization, users,
                new PagedListHolder<UserViewBean>());
    } else {/*w  w w  . ja  v  a  2  s . c o  m*/
        userViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (userViewBeanPagedListHolder == null) {
            userViewBeanPagedListHolder = initList(request, sessionKey, currentLocalization, users,
                    userViewBeanPagedListHolder);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = userViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                userViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                userViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, userViewBeanPagedListHolder);

    formFactory.buildUserQuickSearchForm(request, modelAndView);

    return modelAndView;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.batch.BatchController.java

protected void initPaginationResult(final HttpServletRequest request,
        final ModelAndViewThemeDevice modelAndView, final Localization currentLocalization,
        final List<BatchProcessObject> batchProcessObjects) throws Exception {
    String url = requestUtil.getCurrentRequestUrl(request);

    String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    PagedListHolder<BatchViewBean> batchViewBeanPagedListHolder;

    if (StringUtils.isEmpty(page)) {
        batchViewBeanPagedListHolder = initList(request, sessionKey, currentLocalization, batchProcessObjects,
                new PagedListHolder<BatchViewBean>());
    } else {/*from  w  w w .j  a  va  2s  .  com*/
        batchViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (batchViewBeanPagedListHolder == null) {
            batchViewBeanPagedListHolder = initList(request, sessionKey, currentLocalization,
                    batchProcessObjects, batchViewBeanPagedListHolder);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = batchViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                batchViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                batchViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, batchViewBeanPagedListHolder);

    formFactory.buildBatchQuickSearchForm(request, modelAndView);
}

From source file:fr.hoteia.qalingo.web.mvc.controller.enginesetting.EngineSettingController.java

@RequestMapping(value = BoUrls.ENGINE_SETTING_URL, method = RequestMethod.GET)
public ModelAndView engineSettingList(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            BoUrls.ENGINE_SETTING.getVelocityPage());

    final Localization currentLocalization = requestUtil.getCurrentLocalization(request);
    final Locale locale = currentLocalization.getLocale();
    initLinks(request, modelAndView, locale, null);

    List<EngineSetting> engineSettings = engineSettingService.findEngineSettings();

    String url = requestUtil.getCurrentRequestUrl(request);

    String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    PagedListHolder<EngineSettingViewBean> engineSettingViewBeanPagedListHolder;

    if (StringUtils.isEmpty(page)) {
        engineSettingViewBeanPagedListHolder = initList(request, sessionKey, engineSettings,
                new PagedListHolder<EngineSettingViewBean>());
    } else {/* w w w .j av a2  s .  com*/
        engineSettingViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (engineSettingViewBeanPagedListHolder == null) {
            engineSettingViewBeanPagedListHolder = initList(request, sessionKey, engineSettings,
                    engineSettingViewBeanPagedListHolder);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = engineSettingViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                engineSettingViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                engineSettingViewBeanPagedListHolder.previousPage();
            }
        }
    }
    modelAndView.addObject(Constants.PAGINATION_PAGE_URL, url);
    modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, engineSettingViewBeanPagedListHolder);

    formFactory.buildEngineSettingQuickSearchForm(request, modelAndView);

    return modelAndView;
}