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:de.iteratec.iteraplan.presentation.dialog.GuiSearchController.java

/**
 * Calculates the new page to show in the PagedListHolder, after a navigation action (like goto next, first, previous, last, sorting...) has been performed.
 *//*from www . j  a v  a  2  s .  c  om*/
private void choosePageToShow(T searchDialogMemory, PagedListHolder<?> results) {

    int pageNumber = searchDialogMemory.getCurrentPageNumber();

    if (!StringUtils.isEmpty(searchDialogMemory.getNextPage())
            && "next".equals(searchDialogMemory.getNextPage())) {
        results.setPage(pageNumber);
        results.nextPage();
        searchDialogMemory.setNextPage("");
    } else if (!StringUtils.isEmpty(searchDialogMemory.getPreviousPage())
            && "previous".equals(searchDialogMemory.getPreviousPage())) {
        results.setPage(pageNumber);
        results.previousPage();
        searchDialogMemory.setPreviousPage("");
    } else if (!StringUtils.isEmpty(searchDialogMemory.getNextPage())
            && "last".equals(searchDialogMemory.getNextPage())) {
        results.setPage(results.getLastLinkedPage());
    } else if (!StringUtils.isEmpty(searchDialogMemory.getPreviousPage())
            && "first".equals(searchDialogMemory.getPreviousPage())) {
        results.setPage(results.getFirstLinkedPage());
    }

    searchDialogMemory.setCurrentPageNumber(results.getPage());
    searchDialogMemory.setNextPageToShow(Boolean.FALSE);
}

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

protected void initPaginationResult(final HttpServletRequest request,
        final ModelAndViewThemeDevice modelAndView, final List<BatchProcessObject> batchProcessObjects)
        throws Exception {
    final RequestData requestData = requestUtil.getRequestData(request);

    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, batchProcessObjects,
                new PagedListHolder<BatchViewBean>());
    } else {/* w w  w.j  a v  a 2  s.  com*/
        batchViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (batchViewBeanPagedListHolder == null) {
            batchViewBeanPagedListHolder = initList(request, sessionKey, 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);

    backofficeFormFactory.buildBatchQuickSearchForm(requestData);
}

From source file:org.hoteia.qalingo.web.mvc.controller.catalog.ProductLineController.java

@RequestMapping(FoUrls.CATEGORY_AS_LINE_URL)
public ModelAndView productLine(final HttpServletRequest request, final Model model,
        @PathVariable(RequestConstants.URL_PATTERN_CATEGORY_CODE) final String categoryCode,
        final SearchForm searchForm) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            FoUrls.CATEGORY_AS_LINE.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);
    final Cart currentCart = requestData.getCart();

    final CatalogCategoryVirtual catalogCategory = catalogCategoryService.getVirtualCatalogCategoryByCode(
            categoryCode, requestData.getVirtualCatalogCode(), requestData.getMasterCatalogCode(),
            new FetchPlan(categoryVirtualFetchPlans));

    if (catalogCategory != null) {
        final CatalogCategoryViewBean catalogCategoryViewBean = frontofficeViewBeanFactory
                .buildViewBeanVirtualCatalogCategory(requestUtil.getRequestData(request), catalogCategory);

        String sortBy = request.getParameter("sortBy");
        String orderBy = request.getParameter("orderBy");
        String pageSizeParameter = request.getParameter("pageSize");
        String pageParameter = request.getParameter("page");
        String mode = request.getParameter("mode");

        int page = NumberUtils.toInt(pageParameter, 1) - 1;
        int pageSize = NumberUtils.toInt(pageSizeParameter, 9);

        List<ProductMarketingViewBean> productMarketings = catalogCategoryViewBean.getProductMarketings();
        PagedListHolder<ProductMarketingViewBean> productList = new PagedListHolder<ProductMarketingViewBean>(
                productMarketings);//from w  ww.  java2  s.  c  o m
        productList.setPageSize(pageSize);
        productList.setPage(page);

        int pageCurrent = productList.getPage();
        if (pageCurrent < page) {
            for (int i = pageCurrent; i < page; i++) {
                productList.nextPage();
            }
        } else if (pageCurrent > page) {
            for (int i = page; i < pageCurrent; i++) {
                productList.previousPage();
            }
        }

        catalogCategoryViewBean.setProductMarketings(productList.getPageList());

        final CartViewBean cartViewBean = frontofficeViewBeanFactory
                .buildViewBeanCart(requestUtil.getRequestData(request), currentCart);
        modelAndView.addObject(ModelConstants.CART_VIEW_BEAN, cartViewBean);

        final CatalogBreadcrumbViewBean catalogBreadcrumbViewBean = frontofficeViewBeanFactory
                .buildViewBeanCatalogBreadcrumb(requestUtil.getRequestData(request), catalogCategory);
        model.addAttribute(ModelConstants.CATALOG_BREADCRUMB_VIEW_BEAN, catalogBreadcrumbViewBean);

        model.addAttribute(ModelConstants.CATALOG_CATEGORY_VIEW_BEAN, catalogCategoryViewBean);
        model.addAttribute("sortBy", sortBy);
        model.addAttribute("pageSize", pageSize);
        model.addAttribute("orderBy", orderBy);
        model.addAttribute("currentPage", page);
        model.addAttribute("mode", mode);
        model.addAttribute("totalPage", productList.getPageCount());

        loadRecentProducts(requestData, model);

        Object[] params = { catalogCategoryViewBean.getI18nName() };
        overrideDefaultPageTitle(request, modelAndView, FoUrls.CATEGORY_AS_LINE.getKey(), params);

        model.addAttribute(ModelConstants.BREADCRUMB_VIEW_BEAN,
                buildBreadcrumbViewBean(requestData, catalogCategory));

        model.addAttribute(ModelConstants.SEO_DATA_VIEW_BEAN, initSeo(request, catalogCategoryViewBean));

        model.addAttribute(ModelConstants.PRODUCT_BRANDS_VIEW_BEAN, brandList(request, model));

        return modelAndView;
    }
    final String urlRedirect = urlService.generateRedirectUrl(FoUrls.HOME, requestUtil.getRequestData(request));
    return new ModelAndView(new RedirectView(urlRedirect));
}

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

protected void displayList(final HttpServletRequest request, final Model model, final RequestData requestData)
        throws Exception {
    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 {//from w  w w  . jav a  2s.  c o m
        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();
            }
        }
    }
    model.addAttribute(Constants.PAGINATION_PAGE_URL, url);
    model.addAttribute(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, customerViewBeanPagedListHolder);
}

From source file:org.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 RequestData requestData = requestUtil.getRequestData(request);
    final Customer customer = requestData.getCustomer();

    final Customer reloadedCustomer = customerService.getCustomerById(customer.getId(),
            FetchPlanGraphCustomer.fullCustomerFetchPlan());

    List<OrderPurchase> orderPurchases = orderPurchaseService
            .findOrdersByCustomerId(reloadedCustomer.getId().toString());
    if (orderPurchases != null && orderPurchases.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, orderPurchases,
                    new PagedListHolder<OrderViewBean>());
        } else {/*from  w w  w . j a v  a  2 s .co  m*/
            orderViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
            if (orderViewBeanPagedListHolder == null) {
                orderViewBeanPagedListHolder = initList(request, sessionKey, orderPurchases,
                        orderViewBeanPagedListHolder);
            }
            int pageTarget = new Integer(page) - 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);
    }

    Object[] params = { customer.getLastname(), customer.getFirstname() };
    overrideDefaultPageTitle(request, modelAndView, FoUrls.PERSONAL_ORDER_LIST.getKey(), params);
    return modelAndView;
}

From source file:org.hoteia.qalingo.web.mvc.controller.deliverymethod.DeliveryMethodController.java

protected void displayList(final HttpServletRequest request, final Model model, final RequestData requestData)
        throws Exception {
    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    String sessionKey = "PagedListHolder_DeliveryMethods";

    PagedListHolder<DeliveryMethodViewBean> deliveryMethodViewBeanPagedListHolder = new PagedListHolder<DeliveryMethodViewBean>();

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

    } else {//from  w ww  .  j ava  2 s .c  om
        deliveryMethodViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(sessionKey);
        if (deliveryMethodViewBeanPagedListHolder == null) {
            deliveryMethodViewBeanPagedListHolder = initList(request, sessionKey, requestData);
        }
        int pageTarget = new Integer(page).intValue() - 1;
        int pageCurrent = deliveryMethodViewBeanPagedListHolder.getPage();
        if (pageCurrent < pageTarget) {
            for (int i = pageCurrent; i < pageTarget; i++) {
                deliveryMethodViewBeanPagedListHolder.nextPage();
            }
        } else if (pageCurrent > pageTarget) {
            for (int i = pageTarget; i < pageCurrent; i++) {
                deliveryMethodViewBeanPagedListHolder.previousPage();
            }
        }
    }
    model.addAttribute(Constants.PAGINATION_PAGE_URL, url);
    model.addAttribute(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, deliveryMethodViewBeanPagedListHolder);
}

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

protected void displayList(final HttpServletRequest request, final Model model, final RequestData requestData)
        throws Exception {
    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);

    PagedListHolder<EngineSettingViewBean> engineSettingViewBeanPagedListHolder = new PagedListHolder<EngineSettingViewBean>();

    if (StringUtils.isEmpty(page)) {
        engineSettingViewBeanPagedListHolder = initList(request, SESSION_KEY, requestData);

    } else {/*from   w ww .j a v a 2  s  . co m*/
        engineSettingViewBeanPagedListHolder = (PagedListHolder) request.getSession().getAttribute(SESSION_KEY);
        if (engineSettingViewBeanPagedListHolder == null) {
            engineSettingViewBeanPagedListHolder = initList(request, SESSION_KEY, requestData);
        }
        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();
            }
        }
    }
    model.addAttribute(Constants.PAGINATION_PAGE_URL, url);
    model.addAttribute(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, engineSettingViewBeanPagedListHolder);
}

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

protected void displayList(final HttpServletRequest request, final Model model, final RequestData requestData)
        throws Exception {
    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 {/*from www  .  j  a va  2s .  c om*/
        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();
            }
        }
    }
    model.addAttribute(Constants.PAGINATION_PAGE_URL, url);
    model.addAttribute(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, orderViewBeanPagedListHolder);
}

From source file:org.hoteia.qalingo.web.mvc.controller.paymentgateway.PaymentGatewayController.java

protected void displayList(final HttpServletRequest request, final Model model, final RequestData requestData)
        throws Exception {
    String url = request.getRequestURI();
    String page = request.getParameter(Constants.PAGINATION_PAGE_PARAMETER);
    String sessionKey = "PagedListHolder_PaymentGateways";

    PagedListHolder<PaymentGatewayViewBean> paymentGatewayViewBeanPagedListHolder = new PagedListHolder<PaymentGatewayViewBean>();

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

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

From source file:org.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_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 {/*from  w  w w.  j a va 2s. co  m*/
        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;
}