List of usage examples for org.springframework.ui Model containsAttribute
boolean containsAttribute(String attributeName);
From source file:fi.koku.kks.controller.CollectionController.java
@RenderMapping(params = "action=showCollection") public String show(PortletSession session, @ModelAttribute(value = "child") Person child, @ModelAttribute(value = "collectionForm") CollectionForm collectionForm, @RequestParam(value = "collection") String collection, @RequestParam(value = "print", required = false) String print, @RequestParam(value = "error", required = false) String error, RenderResponse response, Model model) { LOG.debug("show collection"); try {/* w w w . j a v a 2 s .c o m*/ KKSCollection c = kksService.getKksCollection(collection, Utils.getUserInfoFromSession(session)); collectionForm.setEntries(c.getEntries()); session.setAttribute("kks.collection", c); String pic = Utils.getPicFromSession(session); boolean parent = c.isParent(); boolean canSave = !parent || hasParentGroups(c.getCollectionClass()); model.addAttribute("child", child); model.addAttribute("collection", c); model.addAttribute("authorized", kksService.getAuthorizedRegistries(pic)); model.addAttribute("master", parent || VALID.equals(c.getUserConsentStatus())); model.addAttribute("parent", parent); model.addAttribute("empty_collection", c == null || c.getEntries() == null || c.getEntries().size() == 0); model.addAttribute("can_save", canSave); if (!model.containsAttribute("version")) { Version v = new Version(); v.setName(c == null ? "" : c.getName()); model.addAttribute("version", v); } if (StringUtils.isNotEmpty(error)) { model.addAttribute("error", error); } if (StringUtils.isNotEmpty(print)) { model.addAttribute("print_mode", print); } return "collection"; } catch (ServiceFault e) { LOG.error("Failed to get KKS collection " + collection); return "error"; } }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.B2BUserGroupManagementPageController.java
@RequestMapping(value = "/edit", method = RequestMethod.GET) @RequireHardLogIn/* www . j a va2 s .co m*/ public String editUserGroup(@RequestParam("usergroup") final String usergroup, final Model model) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder .createManageUserGroupDetailsBreadCrumbs(usergroup); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-usergroups/edit/?usergroup=%s", urlEncode(usergroup)), getMessageSource().getMessage("text.company.manageUsergroups.editUsergroup.breadcrumb", new Object[] { usergroup }, "Edit {0} Usergroup ", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (!model.containsAttribute("b2BUserGroupForm")) { final B2BUserGroupForm b2BUserGroupForm = new B2BUserGroupForm(); final B2BUserGroupData userGroupData = b2bUserGroupFacade.getB2BUserGroup(usergroup); if (userGroupData == null) { GlobalMessages.addErrorMessage(model, "usergroup.notfound"); } else { b2BUserGroupForm.setOriginalUid(userGroupData.getUid()); if (userGroupData.getUnit() != null) { b2BUserGroupForm.setParentUnit(userGroupData.getUnit().getUid()); } b2BUserGroupForm.setUid(userGroupData.getUid()); b2BUserGroupForm.setName(userGroupData.getName()); } model.addAttribute(b2BUserGroupForm); } model.addAttribute("branchSelectOptions", getBranchSelectOptions(b2bUnitFacade.getBranchNodes())); model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW); return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUsergroupEditPage; }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.B2BUserGroupManagementPageController.java
@RequestMapping(value = "/edit", method = RequestMethod.GET) @RequireHardLogIn/*from w w w .j ava2 s. c o m*/ public String editUserGroup(@RequestParam("usergroup") final String usergroup, final Model model) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder .createManageUserGroupDetailsBreadCrumbs(usergroup); breadcrumbs.add(new Breadcrumb( String.format("/my-company/organization-management/manage-usergroups/edit/?usergroup=%s", urlEncode(usergroup)), getMessageSource().getMessage("text.company.manageUsergroups.editUsergroup.breadcrumb", new Object[] { usergroup }, "Edit {0} Usergroup ", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); if (!model.containsAttribute("b2BUserGroupForm")) { final B2BUserGroupForm b2BUserGroupForm = new B2BUserGroupForm(); final B2BUserGroupData userGroupData = b2bCommerceB2BUserGroupFacade.getB2BUserGroup(usergroup); if (userGroupData == null) { GlobalMessages.addErrorMessage(model, "usergroup.notfound"); } else { b2BUserGroupForm.setOriginalUid(userGroupData.getUid()); if (userGroupData.getUnit() != null) { b2BUserGroupForm.setParentUnit(userGroupData.getUnit().getUid()); } b2BUserGroupForm.setUid(userGroupData.getUid()); b2BUserGroupForm.setName(userGroupData.getName()); } model.addAttribute(b2BUserGroupForm); } model.addAttribute("branchSelectOptions", getBranchSelectOptions(this.companyB2BCommerceFacade.getBranchNodes())); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUsergroupEditPage; }
From source file:de.hybris.platform.commerceorgaddon.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/addcostcenter", method = RequestMethod.GET) @RequireHardLogIn//from w ww .jav a2 s .c om public String addCostCenterToUnit(@RequestParam("unit") final String unit, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { final B2BUnitData unitData = b2bUnitFacade.getUnitForUid(unit); if (unitData == null) { GlobalMessages.addErrorMessage(model, "b2bunit.notfound"); } else if (!model.containsAttribute("b2BCostCenterForm")) { final B2BCostCenterForm b2BCostCenterForm = new B2BCostCenterForm(); b2BCostCenterForm.setParentB2BUnit(unitData.getUid()); model.addAttribute(b2BCostCenterForm); } final String addCostCenterUrl = addCostCenter(model); 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/addcostcenter?unit=%s", urlEncode(unit)), getMessageSource().getMessage("text.company.manage.units.addCostCenter.breadcrumb", new Object[] { unit }, "Create Cost Center for Unit: {0} ", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); model.addAttribute("title", getMessageSource().getMessage("text.company.manage.units.create.costCenter.title", new Object[] { unitData.getName() }, "Create Cost Center for Unit: {0}", getI18nService().getCurrentLocale())); model.addAttribute("cancelUrl", getCancelUrl(MANAGE_UNIT_DETAILS_URL, request.getContextPath(), unit)); model.addAttribute("saveUrl", String.format("%s/my-company/organization-management/manage-units/addcostcenter?unit=%s", request.getContextPath(), urlEncode(unit))); return addCostCenterUrl; }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.BusinessUnitManagementPageController.java
@RequestMapping(value = "/addcostcenter", method = RequestMethod.GET) @RequireHardLogIn/* w ww. j ava 2 s .co m*/ public String addCostCenterToUnit(@RequestParam("unit") final String unit, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { final B2BUnitData unitData = companyB2BCommerceFacade.getUnitForUid(unit); if (unitData == null) { GlobalMessages.addErrorMessage(model, "b2bunit.notfound"); } else if (!model.containsAttribute("b2BCostCenterForm")) { final B2BCostCenterForm b2BCostCenterForm = new B2BCostCenterForm(); b2BCostCenterForm.setParentB2BUnit(unitData.getUid()); model.addAttribute(b2BCostCenterForm); } final String addCostCenterUrl = addCostCenter(model); 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/addcostcenter?unit=%s", urlEncode(unit)), getMessageSource().getMessage("text.company.manage.units.addCostCenter.breadcrumb", new Object[] { unit }, "Create Cost Center for Unit: {0} ", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); model.addAttribute("title", getMessageSource().getMessage("text.company.manage.units.create.costCenter.title", new Object[] { unitData.getName() }, "Create Cost Center for Unit: {0}", getI18nService().getCurrentLocale())); model.addAttribute("cancelUrl", String.format("%s/my-company/organization-management/manage-units/details?unit=%s", request.getContextPath(), urlEncode(unit))); model.addAttribute("saveUrl", String.format("%s/my-company/organization-management/manage-units/addcostcenter?unit=%s", request.getContextPath(), urlEncode(unit))); return addCostCenterUrl; }
From source file:com.ctc.storefront.controllers.pages.CartPageController.java
@SuppressWarnings("boxing") @ResponseBody// w w w . j a v a 2s .c o m @RequestMapping(value = "/updateMultiD", method = RequestMethod.POST) public CartData updateCartQuantitiesMultiD(@RequestParam("entryNumber") final Integer entryNumber, @RequestParam("productCode") final String productCode, final Model model, @Valid final UpdateQuantityForm form, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { for (final ObjectError error : bindingResult.getAllErrors()) { if ("typeMismatch".equals(error.getCode())) { GlobalMessages.addErrorMessage(model, "basket.error.quantity.invalid"); } else { GlobalMessages.addErrorMessage(model, error.getDefaultMessage()); } } } else { try { final CartModificationData cartModification = getCartFacade() .updateCartEntry(getOrderEntryData(form.getQuantity(), productCode, entryNumber)); if (cartModification.getStatusCode().equals(SUCCESSFUL_MODIFICATION_CODE)) { GlobalMessages.addMessage(model, GlobalMessages.CONF_MESSAGES_HOLDER, cartModification.getStatusMessage(), null); } else if (!model.containsAttribute(ERROR_MSG_TYPE)) { GlobalMessages.addMessage(model, GlobalMessages.ERROR_MESSAGES_HOLDER, cartModification.getStatusMessage(), null); } } catch (final CommerceCartModificationException ex) { LOG.warn("Couldn't update product with the entry number: " + entryNumber + ".", ex); } } return getCartFacade().getSessionCart(); }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/my-quote/" + ORDER_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET) @RequireHardLogIn/* ww w. j a va 2 s . c o m*/ public String quotesDetails(@PathVariable("orderCode") final String orderCode, final Model model) throws CMSItemNotFoundException { try { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); model.addAttribute("orderData", orderDetails); final List<B2BOrderHistoryEntryData> orderHistoryEntries = orderFacade .getOrderHistoryEntryData(orderCode); model.addAttribute("orderHistoryEntryData", orderHistoryEntries); model.addAttribute(new ReorderForm()); if (!model.containsAttribute("quoteOrderDecisionForm")) { model.addAttribute("quoteOrderDecisionForm", new QuoteOrderForm()); } final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null); breadcrumbs.add(new Breadcrumb("/my-account/my-quotes", getMessageSource().getMessage( "text.account.manageQuotes.breadcrumb", null, getI18nService().getCurrentLocale()), null)); breadcrumbs.add(new Breadcrumb("/my-account/my-quotes/" + orderDetails.getCode(), getMessageSource().getMessage("text.account.manageQuotes.details.breadcrumb", new Object[] { orderDetails.getCode() }, "Quote Details {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); } catch (final UnknownIdentifierException e) { LOG.warn("Attempted to load a order that does not exist or is not visible", e); return REDIRECT_MY_ACCOUNT; } storeCmsPageInModel(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountQuoteDetailPage; }
From source file:com.jnj.b2b.storefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/my-quote/" + ORDER_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET) @RequireHardLogIn// w w w. j a v a 2 s .c o m public String quotesDetails(@PathVariable("orderCode") final String orderCode, final Model model) throws CMSItemNotFoundException { try { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); model.addAttribute("orderData", orderDetails); final List<B2BOrderHistoryEntryData> orderHistoryEntries = orderFacade .getOrderHistoryEntryData(orderCode); model.addAttribute("orderHistoryEntryData", orderHistoryEntries); model.addAttribute(new ReorderForm()); if (!model.containsAttribute("quoteOrderDecisionForm")) { model.addAttribute("quoteOrderDecisionForm", new QuoteOrderForm()); } final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null); breadcrumbs.add(new Breadcrumb("/my-account/my-quotes", getMessageSource().getMessage( "text.account.manageQuotes.breadcrumb", null, getI18nService().getCurrentLocale()), null)); breadcrumbs.add(new Breadcrumb("/my-account/my-quotes/" + orderDetails.getCode(), getMessageSource().getMessage("text.account.manageQuotes.details.breadcrumb", new Object[] { orderDetails.getCode() }, "Quote Details {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); } catch (final UnknownIdentifierException e) { LOG.warn("Attempted to load a order that does not exist or is not visible", e); return REDIRECT_MY_ACCOUNT; } storeCmsPageInModel(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountQuoteDetailPage; }
From source file:org.training.storefront.controllers.pages.checkout.CheckoutController.java
protected void processOrderCode(final String orderCode, final Model model, final HttpServletRequest request) throws CMSItemNotFoundException { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); 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);//from ww w . jav a 2 s .co m } } 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"); }
From source file:cec.easyshop.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(); }/* ww w . j ava2 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); } } 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(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW); return ControllerConstants.Views.Pages.Checkout.CheckoutConfirmationPage; }