List of usage examples for org.springframework.ui Model containsAttribute
boolean containsAttribute(String attributeName);
From source file:com.epam.hybris.test.storefront.controllers.pages.CheckoutController.java
protected String processOrderCode(final String orderCode, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); if (orderDetails.isGuestCustomer() && !StringUtils.substringBefore(orderDetails.getUser().getUid(), "|") .equals(getSessionService().getAttribute(WebConstants.ANONYMOUS_CHECKOUT_GUID))) { return getCheckoutRedirectUrl(); }//w w w . j av a 2 s . c om if (orderDetails.getEntries() != null && !orderDetails.getEntries().isEmpty()) { for (final OrderEntryData entry : orderDetails.getEntries()) { final String productCode = entry.getProduct().getCode(); final ProductData product = productFacade.getProductForCodeAndOptions(productCode, Arrays.asList(ProductOption.BASIC, ProductOption.PRICE, ProductOption.CATEGORIES)); entry.setProduct(product); } } orderDetails.setNet(true); model.addAttribute("orderCode", orderCode); model.addAttribute("orderData", orderDetails); model.addAttribute("allItems", orderDetails.getEntries()); model.addAttribute("deliveryAddress", orderDetails.getDeliveryAddress()); model.addAttribute("deliveryMode", orderDetails.getDeliveryMode()); model.addAttribute("paymentInfo", orderDetails.getPaymentInfo()); model.addAttribute("pageType", PageType.ORDERCONFIRMATION.name()); final String uid; if (orderDetails.isGuestCustomer() && !model.containsAttribute("guestRegisterForm")) { final GuestRegisterForm guestRegisterForm = new GuestRegisterForm(); guestRegisterForm.setOrderCode(orderDetails.getGuid()); uid = orderDetails.getPaymentInfo().getBillingAddress().getEmail(); guestRegisterForm.setUid(uid); model.addAttribute(guestRegisterForm); } else { uid = orderDetails.getUser().getUid(); } model.addAttribute("email", uid); final String continueUrl = (String) getSessionService().getAttribute(WebConstants.CONTINUE_URL); model.addAttribute(CONTINUE_URL_KEY, (continueUrl != null && !continueUrl.isEmpty()) ? continueUrl : ROOT); final AbstractPageModel cmsPage = getContentPageForLabelOrId(CHECKOUT_ORDER_CONFIRMATION_CMS_PAGE_LABEL); storeCmsPageInModel(model, cmsPage); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(CHECKOUT_ORDER_CONFIRMATION_CMS_PAGE_LABEL)); model.addAttribute("metaRobots", "noindex,nofollow"); return ControllerConstants.Views.Pages.Checkout.CheckoutConfirmationPage; }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.UserManagementPageController.java
@RequestMapping(value = "/edit-approver", method = RequestMethod.POST) @RequireHardLogIn//from w w w. j a v a 2 s. c om public String editUsersApprover(@RequestParam("user") final String user, @RequestParam("approver") final String approver, @Valid final B2BCustomerForm b2BCustomerForm, final BindingResult bindingResult, final Model model, final HttpServletRequest request, final RedirectAttributes redirectModel) throws CMSItemNotFoundException { model.addAttribute("cancelUrl", getCancelUrl(MANAGE_USER_DETAILS_URL, request.getContextPath(), user)); model.addAttribute("saveUrl", String.format( "%s/my-company/organization-management/manage-users/edit-approver?user=%s&approver=%s", request.getContextPath(), urlEncode(user), urlEncode(approver))); final String editUserUrl = super.editUser(user, b2BCustomerForm, bindingResult, model, redirectModel); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserDetailsBreadcrumb(user); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-units/edit-approver?user=%s&approver=%s", urlEncode(user), urlEncode(approver)), getMessageSource().getMessage("text.company.manageusers.edit", new Object[] { approver }, "Edit {0} User", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (bindingResult.hasErrors() || model.containsAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER)) { return editUserUrl; } else { return String.format(REDIRECT_TO_USER_DETAILS, urlEncode(user)); } }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/edit", method = RequestMethod.GET) @RequireHardLogIn// w ww.jav a 2 s. c om public String editUnit(@RequestParam("unit") final String unit, final Model model) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUnitsDetailsBreadcrumbs(unit); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-units/edit?unit=%s", urlEncode(unit)), getMessageSource().getMessage("text.company.manage.units.editUnit.breadcrumb", new Object[] { unit }, "Edit Unit: {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (!model.containsAttribute("b2BUnitForm")) { final B2BUnitData unitData = companyB2BCommerceFacade.getUnitForUid(unit); final B2BUnitForm b2BUnitForm = new B2BUnitForm(); b2BUnitForm.setOriginalUid(unitData.getUid()); if (unitData.getUnit() != null) { b2BUnitForm.setParentUnit(unitData.getUnit().getUid()); } b2BUnitForm.setApprovalProcessCode(unitData.getApprovalProcessCode()); b2BUnitForm.setUid(unitData.getUid()); b2BUnitForm.setName(unitData.getName()); model.addAttribute(b2BUnitForm); } model.addAttribute("branchSelectOptions", getBranchSelectOptions(b2bCommerceUnitFacade.getAllowedParentUnits(unit))); model.addAttribute("action", "edit"); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUnitEditPage; }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/edit", method = RequestMethod.GET) @RequireHardLogIn/*from w w w . j ava 2s . com*/ public String editUnit(@RequestParam("unit") final String unit, final Model model) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUnitsDetailsBreadcrumbs(unit); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-units/edit?unit=%s", urlEncode(unit)), getMessageSource().getMessage("text.company.manage.units.editUnit.breadcrumb", new Object[] { unit }, "Edit Unit: {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (!model.containsAttribute("b2BUnitForm")) { final B2BUnitData unitData = b2bUnitFacade.getUnitForUid(unit); final B2BUnitForm b2BUnitForm = new B2BUnitForm(); b2BUnitForm.setOriginalUid(unitData.getUid()); if (unitData.getUnit() != null) { b2BUnitForm.setParentUnit(unitData.getUnit().getUid()); } b2BUnitForm.setApprovalProcessCode(unitData.getApprovalProcessCode()); b2BUnitForm.setUid(unitData.getUid()); b2BUnitForm.setName(unitData.getName()); model.addAttribute(b2BUnitForm); } model.addAttribute("branchSelectOptions", getBranchSelectOptions(b2bUnitFacade.getAllowedParentUnits(unit))); model.addAttribute("action", "edit"); model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW); model.addAttribute("businessProcesses", getBusinessProcesses()); return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUnitEditPage; }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/edituser", method = RequestMethod.POST) @RequireHardLogIn//from w w w. j ava 2 s .com public String editCustomerOfUnit(@RequestParam("unit") final String unit, @RequestParam("user") final String user, @Valid final B2BCustomerForm b2bCustomerForm, final BindingResult bindingResult, final Model model, final HttpServletRequest request, final RedirectAttributes redirectModel) throws CMSItemNotFoundException { final String url = editUser(user, b2bCustomerForm, bindingResult, model, redirectModel); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUnitsDetailsBreadcrumbs(unit); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-units/edituser/?unit=%s&user=%s", urlEncode(unit), urlEncode(user)), getMessageSource().getMessage("text.company.manage.units.editcustomer.breadcrumb", new Object[] { user }, "Edit Customer {0} ", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (bindingResult.hasErrors() || model.containsAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER)) { model.addAttribute("action", "manage.units"); model.addAttribute("saveUrl", String.format( request.getContextPath() + "/my-company/organization-management/manage-units/edituser/?unit=%s&user=%s", urlEncode(unit), urlEncode(user))); model.addAttribute("cancelUrl", getCancelUrl(MANAGE_UNIT_DETAILS_URL, request.getContextPath(), unit)); return url; } else { return String.format(REDIRECT_TO_UNIT_DETAILS, urlEncode(unit)); } }
From source file:com.daimler.spm.b2bacceleratoraddon.controllers.pages.checkout.steps.SummaryCheckoutStepController.java
@RequestMapping(value = "/view", method = RequestMethod.GET) @RequireHardLogIn/*from www . j av a 2 s . co m*/ @Override @PreValidateQuoteCheckoutStep @PreValidateCheckoutStep(checkoutStep = SUMMARY) public String enterStep(final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException, CommerceCartModificationException { final CartData cartData = getCheckoutFacade().getCheckoutCart(); if (cartData.getEntries() != null && !cartData.getEntries().isEmpty()) { for (final OrderEntryData entry : cartData.getEntries()) { final String productCode = entry.getProduct().getCode(); final ProductData product = getProductFacade().getProductForCodeAndOptions(productCode, Arrays.asList(ProductOption.BASIC, ProductOption.PRICE, ProductOption.VARIANT_MATRIX_BASE, ProductOption.PRICE_RANGE)); entry.setProduct(product); } } model.addAttribute("cartData", cartData); model.addAttribute("allItems", cartData.getEntries()); model.addAttribute("deliveryAddress", cartData.getDeliveryAddress()); model.addAttribute("deliveryMode", cartData.getDeliveryMode()); model.addAttribute("paymentInfo", cartData.getPaymentInfo()); // TODO:Make configuration hmc driven than hardcoding in controllers model.addAttribute("nDays", getNumberRange(1, 30)); model.addAttribute("nthDayOfMonth", getNumberRange(1, 31)); model.addAttribute("nthWeek", getNumberRange(1, 12)); model.addAttribute("daysOfWeek", getB2BCheckoutFacade().getDaysOfWeekForReplenishmentCheckoutSummary()); // Only request the security code if the SubscriptionPciOption is set to Default. final boolean requestSecurityCode = (CheckoutPciOptionEnum.DEFAULT .equals(getCheckoutFlowFacade().getSubscriptionPciOption())); model.addAttribute("requestSecurityCode", Boolean.valueOf(requestSecurityCode)); if (!model.containsAttribute("placeOrderForm")) { final PlaceOrderForm placeOrderForm = new PlaceOrderForm(); // TODO: Make setting of default recurrence enum value hmc driven rather hard coding in controller placeOrderForm.setReplenishmentRecurrence(B2BReplenishmentRecurrenceEnum.MONTHLY); placeOrderForm.setnDays("14"); final List<DayOfWeek> daysOfWeek = new ArrayList<DayOfWeek>(); daysOfWeek.add(DayOfWeek.MONDAY); placeOrderForm.setnDaysOfWeek(daysOfWeek); model.addAttribute("placeOrderForm", placeOrderForm); } storeCmsPageInModel(model, getContentPageForLabelOrId(MULTI_CHECKOUT_SUMMARY_CMS_PAGE_LABEL)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MULTI_CHECKOUT_SUMMARY_CMS_PAGE_LABEL)); model.addAttribute(WebConstants.BREADCRUMBS_KEY, getResourceBreadcrumbBuilder().getBreadcrumbs("checkout.multi.summary.breadcrumb")); model.addAttribute("metaRobots", "noindex,nofollow"); setCheckoutStepLinksForModel(model, getCheckoutStep()); return Daimlerspmb2bacceleratoraddonControllerConstants.Views.Pages.MultiStepCheckout.CheckoutSummaryPage; }
From source file:com.epam.training.storefront.controllers.pages.payment.PaymentDetailsPageController.java
protected void setupSilentOrderPostPage(final SopPaymentDetailsForm sopPaymentDetailsForm, final Model model, final String clientIpAddress, final String targetArea, final CCPaymentInfoData ccPaymentInfoData) { model.addAttribute("targetArea", targetArea); try {/* www . ja v a2 s . c om*/ final String postUrl = getSubscriptionFacade().hpfUrl(); final SubscriptionPaymentData initResult = getSubscriptionFacade().initializeTransaction( clientIpAddress, getSopResponseUrl(true, targetArea), getSopResponseUrl(true, targetArea), new HashMap<String, String>()); final String sessionToken = initResult.getParameters().get("sessionTransactionToken"); Assert.notNull(sessionToken, "Session token may not be null"); Assert.notNull(postUrl, "Post URL may not be null"); getSessionService().setAttribute("authorizationRequestId", clientIpAddress); getSessionService().setAttribute("authorizationRequestToken", sessionToken); model.addAttribute("postUrl", postUrl); model.addAttribute("sessionToken", sessionToken); } catch (final SubscriptionFacadeException e) { model.addAttribute("postUrl", null); model.addAttribute("sessionToken", null); LOG.warn("Failed to initialize session for silent order post page", e); GlobalMessages.addErrorMessage(model, "checkout.multi.sop.globalError"); } catch (final IllegalArgumentException e) { model.addAttribute("postUrl", null); model.addAttribute("sessionToken", null); LOG.warn("Failed to set up silent order post page", e); GlobalMessages.addErrorMessage(model, "checkout.multi.sop.globalError"); } if (!model.containsAttribute("accErrorMsgs")) { setupSopPaymentDetailsForm(sopPaymentDetailsForm, ccPaymentInfoData, targetArea); } model.addAttribute("sopPaymentDetailsForm", sopPaymentDetailsForm); model.addAttribute("paymentInfo", ccPaymentInfoData); }
From source file:com.acc.storefront.controllers.pages.CheckoutController.java
protected String processOrderCode(final String orderCode, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); if (orderDetails.isGuestCustomer() && !StringUtils.substringBefore(orderDetails.getUser().getUid(), "|") .equals(getSessionService().getAttribute(WebConstants.ANONYMOUS_CHECKOUT_GUID))) { return getCheckoutRedirectUrl(); }// w w w . ja va2s . co m if (orderDetails.getEntries() != null && !orderDetails.getEntries().isEmpty()) { for (final OrderEntryData entry : orderDetails.getEntries()) { final String productCode = entry.getProduct().getCode(); final ProductData product = productFacade.getProductForCodeAndOptions(productCode, Arrays.asList(ProductOption.BASIC, ProductOption.PRICE, ProductOption.CATEGORIES)); entry.setProduct(product); } final BaseStoreModel baseStoreModel = baseStoreService.getCurrentBaseStore(); final OrderModel orderModel = checkoutCustomerStrategy.isAnonymousCheckout() ? customerAccountService.getOrderDetailsForGUID(orderCode, baseStoreModel) : customerAccountService.getOrderForCode((CustomerModel) userService.getCurrentUser(), orderCode, baseStoreModel); if (StringUtils.isNotEmpty(orderModel.getUCOID())) { model.addAttribute("UCOID", orderModel.getUCOID()); System.out.println("ucoid" + orderModel.getUCOID()); } } model.addAttribute("orderCode", orderCode); model.addAttribute("orderData", orderDetails); model.addAttribute("allItems", orderDetails.getEntries()); model.addAttribute("deliveryAddress", orderDetails.getDeliveryAddress()); model.addAttribute("deliveryMode", orderDetails.getDeliveryMode()); model.addAttribute("paymentInfo", orderDetails.getPaymentInfo()); model.addAttribute("pageType", PageType.ORDERCONFIRMATION.name()); final String uid = orderDetails.getPaymentInfo().getBillingAddress().getEmail(); model.addAttribute("email", uid); if (orderDetails.isGuestCustomer() && !model.containsAttribute("guestRegisterForm")) { final GuestRegisterForm guestRegisterForm = new GuestRegisterForm(); guestRegisterForm.setOrderCode(orderDetails.getGuid()); guestRegisterForm.setUid(uid); model.addAttribute(guestRegisterForm); } final AbstractPageModel cmsPage = getContentPageForLabelOrId(CHECKOUT_ORDER_CONFIRMATION_CMS_PAGE_LABEL); storeCmsPageInModel(model, cmsPage); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(CHECKOUT_ORDER_CONFIRMATION_CMS_PAGE_LABEL)); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Checkout.CheckoutConfirmationPage; }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/create", method = RequestMethod.GET) @RequireHardLogIn//from ww w .j a va2s .c o m public String createUnit(@RequestParam("unit") final String unit, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_UNITS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs; final B2BUnitData unitData; String parentUnit = ""; if (StringUtils.isNotBlank(unit)) { unitData = b2bUnitFacade.getUnitForUid(unit); breadcrumbs = myCompanyBreadcrumbBuilder.createManageUnitsDetailsBreadcrumbs(unit); model.addAttribute("cancelUrl", getCancelUrl(MANAGE_UNIT_DETAILS_URL, request.getContextPath(), unit)); } else { breadcrumbs = myCompanyBreadcrumbBuilder.createManageUnitsBreadcrumbs(); unitData = b2bUnitFacade.getParentUnit(); parentUnit = unitData == null ? "" : unitData.getName(); } breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-units/create?unit=", getMessageSource().getMessage("text.company.manage.units.createUnit.breadcrumb", new Object[] { StringUtils.isEmpty(parentUnit) ? unit : parentUnit }, "Create Child Unit for Unit: {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); model.addAttribute("unitName", (unitData == null ? "" : unitData.getName())); if (!model.containsAttribute("b2BUnitForm")) { final B2BUnitForm b2BUnitForm = new B2BUnitForm(); b2BUnitForm.setParentUnit((unitData == null ? "" : unitData.getUid())); model.addAttribute(b2BUnitForm); } model.addAttribute("branchSelectOptions", getBranchSelectOptions(b2bUnitFacade.getBranchNodes())); model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW); model.addAttribute("businessProcesses", getBusinessProcesses()); return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUnitCreatePage; }