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

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

Introduction

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

Prototype

public PagedListHolder() 

Source Link

Document

Create a new holder instance.

Usage

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 {/*  w w w .  j  a v a 2 s .c  om*/
            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.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));//from  ww w .  j a v a2 s .  co  m
    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:com.klm.workshop.controller.host.manage.WorkshopController.java

/**
 * List of workshops/*www .  j a va  2 s.co m*/
 * 
 * @param model Objects and view
 * @param page Current pagination page
 * @param search Search value
 * @return The workshops list view
 */
@RequestMapping(value = "/workshops/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model,
        @RequestParam(name = "p", required = false, defaultValue = "0") int page,
        @RequestParam(name = "search", required = false, defaultValue = "") String search) {
    PagedListHolder pagedListHolder = new PagedListHolder();
    pagedListHolder.setSource(workshopDAO.searchAll(search));
    pagedListHolder.setPage(page);

    model.addObject("pagedListHolder", pagedListHolder);
    model.setViewName("host/manage/workshops/index");
    return model;
}

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  w  w .  j av a 2 s.co m*/
    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:com.klm.workshop.controller.host.manage.UserController.java

/**
 * List of users/*from w ww  .j  a  v a2s .c  o  m*/
 * 
 * @param model Objects and view
 * @param page Current pagination page
 * @param search Search value
 * @return The users list view
 */
@RequestMapping(value = "/users/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model,
        @RequestParam(name = "p", required = false, defaultValue = "0") int page,
        @RequestParam(name = "search", required = false, defaultValue = "") String search) {
    PagedListHolder pagedListHolder = new PagedListHolder();
    pagedListHolder.setSource(userDAO.searchAll(search));
    pagedListHolder.setPage(page);

    model.addObject("pagedListHolder", pagedListHolder);
    model.setViewName("host/manage/users/index");
    return model;
}

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));/*from   w  w  w .ja va 2 s.  co  m*/
    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.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));//from  w w w.  ja  va  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_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:com.klm.workshop.controller.host.manage.SessionController.java

/**
 * List of sessions// w ww. ja va  2s .  c  om
 * 
 * @param model Objects and view
 * @param page Current pagination page
 * @param search Search value
 * @return The sessions list view
 */
@RequestMapping(value = "/sessions/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model,
        @RequestParam(name = "p", required = false, defaultValue = "0") int page,
        @RequestParam(name = "search", required = false, defaultValue = "") String search) {
    PagedListHolder pagedListHolder = new PagedListHolder();
    pagedListHolder.setSource(sessionDAO.searchAll(search));
    pagedListHolder.setPage(page);

    model.addObject("pagedListHolder", pagedListHolder);
    model.setViewName("host/manage/sessions/index");
    return model;
}

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 {/*from   w w  w  .  j  av  a 2s.  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.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 a  va 2s .  c  o  m
        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;
}