List of usage examples for org.springframework.beans.support PagedListHolder getPage
public int getPage()
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 ww. ja v a 2 s . c o m 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);// www. j a v a 2s.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 .java 2s . com 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 ww . j a v a 2 s. c o 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 ww w.ja v a 2s . 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 w w . j a v a 2 s . c o 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 {//www.ja v a2s . com 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. j av a 2 s . co 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 ww . j av a 2 s . c o 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; }
From source file:org.hoteia.qalingo.web.mvc.controller.search.CatalogSearchController.java
@RequestMapping(value = FoUrls.CATALOG_SEARCH_URL, method = RequestMethod.GET) public ModelAndView search(final HttpServletRequest request, final Model model, @Valid SearchForm searchForm) throws Exception { ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), FoUrls.CATALOG_SEARCH.getVelocityPage()); final RequestData requestData = requestUtil.getRequestData(request); final MarketArea marketArea = requestData.getMarketArea(); // SANITY CHECK List<String> evictValues = new ArrayList<String>(); evictValues.add("*"); if (StringUtils.isNotEmpty(searchForm.getText()) && evictValues.contains(searchForm.getText())) { return displaySearch(request, model); }//w w w. j a v a2s . c o m if (StringUtils.isEmpty(searchForm.getText()) && searchForm.getPage() == 0) { return displaySearch(request, model); } String sessionKeyPagedListHolder = "Search_ProductMarketing_PagedListHolder_" + request.getSession().getId(); String sessionKeyFacet = "Search_ProductMarketing_Facet_" + request.getSession().getId(); int page = 0; try { page = Integer.parseInt(request.getParameter("page")); } catch (Exception e) { // NO NEED } String mode = request.getParameter(Constants.PAGE_VIEW_MODE); String sortBy = searchForm.getSortBy(); String order = searchForm.getOrder(); int pageSize = searchForm.getPageSize(); final List<String> facetFields = new ArrayList<String>(); facetFields.add(ProductMarketingResponseBean.PRODUCT_MARKETING_SEARCH_FIELD_CATEGORIE_CODES); facetFields.add(ProductMarketingResponseBean.PRODUCT_MARKETING_SEARCH_FIELD_PRODUCT_BRAND_CODE); facetFields.add(ProductMarketingResponseBean.PRODUCT_MARKETING_SEARCH_FIELD_OPTION_DEFINITION_CODES); facetFields.add(ProductMarketingResponseBean.PRODUCT_MARKETING_SEARCH_FIELD_TAG_CODES); try { PagedListHolder<ProductMarketingViewBean> pagedListHolder; if (page == 0 || request.getSession().getAttribute(sessionKeyPagedListHolder) == null) { ProductMarketingResponseBean productMarketingResponseBean = null; String querySearch = getSearchQuery(marketArea, searchForm.getText()); if (searchForm.getPrice() != null) { // if(searchForm.getCatalogCategoryList() != null){ // productMarketingResponseBean = productMarketingSolrService.searchProductMarketing(querySearch, facetFields, searchForm.getPrice().getStartValue(), searchForm.getPrice().getEndValue(), // searchForm.getCatalogCategoryList()); // } else { // productMarketingResponseBean = productMarketingSolrService.searchProductMarketing(querySearch, facetFields, searchForm.getPrice().getStartValue(), searchForm.getPrice().getEndValue()); // } productMarketingResponseBean = productMarketingSolrService.searchProductMarketing(querySearch, facetFields, null); } else { productMarketingResponseBean = productMarketingSolrService.searchProductMarketing(querySearch, facetFields, null); } pagedListHolder = initList(requestData, sessionKeyPagedListHolder, productMarketingResponseBean, pageSize, sortBy, order); // FACETS List<SearchFacetViewBean> facets = frontofficeViewBeanFactory .buildListViewBeanCatalogSearchFacet(requestData, productMarketingResponseBean); modelAndView.addObject(AbstractSolrService.SEARCH_FACET_FIELD_LIST, facets); request.getSession().setAttribute(sessionKeyFacet, facets); } else { pagedListHolder = (PagedListHolder<ProductMarketingViewBean>) request.getSession() .getAttribute(sessionKeyPagedListHolder); // FACETS List<SearchFacetViewBean> facets = (List<SearchFacetViewBean>) request.getSession() .getAttribute(sessionKeyFacet); modelAndView.addObject(AbstractSolrService.SEARCH_FACET_FIELD_LIST, facets); } int pageListPosition = page - 1; int pageCurrent = pagedListHolder.getPage(); if (pageCurrent < pageListPosition) { for (int i = pageCurrent; i < pageListPosition; i++) { pagedListHolder.nextPage(); } } else if (pageCurrent > pageListPosition) { for (int i = pageListPosition; i < pageCurrent; i++) { pagedListHolder.previousPage(); } } modelAndView.addObject(Constants.PAGINATION_PAGE_URL, requestUtil.getCurrentRequestUrl(request)); modelAndView.addObject(Constants.PAGINATION_PAGE_PAGED_LIST_HOLDER, pagedListHolder); modelAndView.addObject(Constants.SEARCH_TEXT, searchForm.getText()); modelAndView.addObject(Constants.PAGINATION_PAGE_SIZE, pagedListHolder.getPageSize()); modelAndView.addObject(Constants.PAGINATION_SORT_BY, sortBy); modelAndView.addObject(Constants.PAGINATION_ORDER, order); modelAndView.addObject(Constants.PRICE_RANGE_PARAMETER, searchForm.getPrice()); // modelAndView.addObject(Constants.CATALOG_CATEGORIES_PARAMETER, searchForm.getCategoriesFilter()); } catch (Exception e) { logger.error("SOLR Error", e); return displaySearch(request, model); } loadRecentProducts(requestData, model); final Cart currentCart = requestData.getCart(); final CartViewBean cartViewBean = frontofficeViewBeanFactory .buildViewBeanCart(requestUtil.getRequestData(request), currentCart); modelAndView.addObject(ModelConstants.CART_VIEW_BEAN, cartViewBean); overrideDefaultPageTitle(request, modelAndView, FoUrls.CATALOG_SEARCH.getKey()); model.addAttribute(ModelConstants.BREADCRUMB_VIEW_BEAN, buildBreadcrumbViewBean(requestData)); return modelAndView; }