List of usage examples for org.springframework.ui Model containsAttribute
boolean containsAttribute(String attributeName);
From source file:de.hybris.platform.chinesepaymentaddon.controllers.pages.ChineseOrderConfirmationController.java
@Override 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 v a 2s . c o 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); } } 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 = StringUtils.substringAfter(orderDetails.getUser().getUid(), "|"); 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); if (ResponsiveUtils.isResponsive()) { return getViewForPage(model); } return ControllerConstants.Views.Pages.Checkout.CheckoutConfirmationPage; }
From source file:de.hybris.platform.sap.productconfig.frontend.controllers.AbstractProductConfigController.java
protected void populateConfigurationModel(final KBKeyData kbKey, final String configId, final String selectedGroup, final Model model, final UiStatus uiStatus, final String cartEntryHandleFromRequest) { if (model.containsAttribute(Sapproductconfigb2baddonConstants.CONFIG_ATTRIBUTE)) { return;/*from ww w . j a v a 2 s .co m*/ } final ConfigurationData configData; if (configId != null) { configData = reloadConfiguration(kbKey, configId, selectedGroup, uiStatus); } else { configData = loadNewConfiguration(kbKey, selectedGroup); } if (cartEntryHandleFromRequest == null) { setCartItemPk(configData); } else { configData.setCartItemPK(cartEntryHandleFromRequest); } model.addAttribute(Sapproductconfigb2baddonConstants.CONFIG_ATTRIBUTE, configData); final BindingResult errors = getBindingResultForConfig(configData); model.addAttribute(BindingResult.MODEL_KEY_PREFIX + Sapproductconfigb2baddonConstants.CONFIG_ATTRIBUTE, errors); }
From source file:de.hybris.platform.yacceleratorstorefront.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(); }/*from www . j a va 2 s.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); } } 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 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.yb2bacceleratorstorefront.controllers.pages.checkout.SingleStepCheckoutController.java
@RequestMapping(value = "/summary", method = { RequestMethod.GET, RequestMethod.POST }) @RequireHardLogIn//w w w .j a va 2 s . c om public String checkoutSummary(final Model model) throws CMSItemNotFoundException { if (!b2bUserGroupProvider.isCurrentUserAuthorizedToCheckOut()) { GlobalMessages.addErrorMessage(model, "checkout.error.invalid.accountType"); return FORWARD_PREFIX + "/cart"; } if (!hasItemsInCart()) { // no items in the cart return FORWARD_PREFIX + "/cart"; } getCheckoutFlowFacade().setDeliveryAddressIfAvailable(); getCheckoutFlowFacade().setDeliveryModeIfAvailable(); getCheckoutFlowFacade().setPaymentInfoIfAvailable(); getCheckoutFlowFacade().setDefaultPaymentTypeForCheckout(); final CartData cartData = getCheckoutFlowFacade().getCheckoutCart(); if (cartData.getEntries() != null && !cartData.getEntries().isEmpty()) { for (final OrderEntryData entry : cartData.getEntries()) { final String productCode = entry.getProduct().getCode(); final ProductData product = productFacade.getProductForCodeAndOptions(productCode, Arrays.asList(ProductOption.BASIC, ProductOption.PRICE)); entry.setProduct(product); } } // Try to set default delivery address and delivery mode if (cartData.getPaymentType() == null) { getCheckoutFlowFacade().setPaymentTypeSelectedForCheckout(CheckoutPaymentType.ACCOUNT.getCode()); } model.addAttribute("cartData", cartData); model.addAttribute("allItems", cartData.getEntries()); model.addAttribute("deliveryAddress", cartData.getDeliveryAddress()); model.addAttribute("deliveryMode", cartData.getDeliveryMode()); model.addAttribute("paymentInfo", cartData.getPaymentInfo()); model.addAttribute("costCenter", cartData.getCostCenter()); model.addAttribute("quoteText", new B2BCommentData()); // 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(new AddressForm()); model.addAttribute(new PaymentDetailsForm()); 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(SINGLE_STEP_CHECKOUT_SUMMARY_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(SINGLE_STEP_CHECKOUT_SUMMARY_CMS_PAGE)); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.SingleStepCheckout.CheckoutSummaryPage; }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.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 {// w w w . ja v a2 s . c o m 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); } model.addAttribute("sopPaymentDetailsForm", sopPaymentDetailsForm); model.addAttribute("paymentInfo", ccPaymentInfoData); }
From source file:eionet.webq.web.controller.PublicPageController.java
/** * Action to be performed on http GET method and path '/'. * * @param model holder for model attributes * @return view name// ww w . ja v a2s . co m */ @RequestMapping(value = "/") public String welcome(Model model) { model.addAttribute("uploadedFiles", allFilesWithConversions()); List<ProjectFile> webformsSortedList = webFormService.sortWebformsAlphabetically(allWebForms()); model.addAttribute("allWebForms", webformsSortedList); String uploadForm = "uploadForm"; if (!model.containsAttribute(uploadForm)) { model.addAttribute(uploadForm, new UploadForm()); } return "index"; }
From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.DisabilitiesFormController.java
private void fillFormIfRequired(final ExecutionYear executionYear, final Model model) { if (!model.containsAttribute("disabilitiesForm")) { model.addAttribute("disabilitiesForm", createDisabilitiesForm(executionYear, getStudent(model))); }// w w w. j a v a2s. c o m final DisabilitiesForm form = (DisabilitiesForm) model.asMap().get("disabilitiesForm"); form.setFirstYearRegistration(false); for (final Registration registration : getStudent(model).getRegistrationsSet()) { if (!registration.isActive()) { continue; } if (registration.getRegistrationYear() != executionYear) { continue; } form.setFirstYearRegistration(true); } }
From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.OriginInformationFormController.java
private void fillFormIfRequired(final Registration registration, Model model) { model.addAttribute("registration", registration); model.addAttribute("districtAndSubdivisionRequired", isDistrictAndSubdivisionRequired()); if (!model.containsAttribute("originInformationForm")) { model.addAttribute("originInformationForm", createOriginInformationForm(registration)); }//from w w w. j a v a2 s. co m final OriginInformationForm form = (OriginInformationForm) model.asMap().get("originInformationForm"); if (!StringUtils.isEmpty(form.getInstitutionOid())) { DomainObject institutionObject = FenixFramework.getDomainObject(form.getInstitutionOid()); if (institutionObject instanceof Unit && FenixFramework.isDomainObjectValid(institutionObject)) { form.setInstitutionName(((Unit) institutionObject).getName()); } else { form.setInstitutionName(form.getInstitutionOid()); } } }
From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.ResidenceInformationFormController.java
private void fillFormIfRequired(Model model) { if (!model.containsAttribute("residenceInformationForm")) { StudentCandidacy candidacy = FirstTimeCandidacyController.getCandidacy(); PersonalIngressionData personalData = FirstTimeCandidacyController.getOrCreatePersonalIngressionData( ExecutionYear.readCurrentExecutionYear(), candidacy.getPrecedentDegreeInformation()); Person person = AccessControl.getPerson(); PersonUlisboaSpecifications personUl = person.getPersonUlisboaSpecifications(); ResidenceInformationForm form = new ResidenceInformationForm(); form.setCountryOfResidence(personalData.getCountryOfResidence()); if (form.getCountryOfResidence() == null) { form.setCountryOfResidence(Country.readDefault()); }// www . j a v a 2 s . c om District district = personalData.getDistrictSubdivisionOfResidence() != null ? personalData.getDistrictSubdivisionOfResidence().getDistrict() : null; form.setDistrictOfResidence(district); DistrictSubdivision districtSubdivisionOfResidence = personalData.getDistrictSubdivisionOfResidence(); form.setDistrictSubdivisionOfResidence(districtSubdivisionOfResidence); PhysicalAddress defaultPhysicalAddress = person.getDefaultPhysicalAddress(); if (defaultPhysicalAddress != null) { form.setAddress(defaultPhysicalAddress.getAddress()); form.setAreaCode( defaultPhysicalAddress.getAreaCode() + " " + defaultPhysicalAddress.getAreaOfAreaCode()); form.setArea(defaultPhysicalAddress.getArea()); form.setParishOfResidence(Parish.findByName(districtSubdivisionOfResidence, person.getDefaultPhysicalAddress().getParishOfResidence()).orElse(null)); } form.setDislocatedFromPermanentResidence(personalData.getDislocatedFromPermanentResidence()); if (personalData.getDislocatedFromPermanentResidence() == Boolean.TRUE) { district = personalData.getSchoolTimeDistrictSubDivisionOfResidence() != null ? personalData.getSchoolTimeDistrictSubDivisionOfResidence().getDistrict() : null; form.setSchoolTimeDistrictOfResidence(district); DistrictSubdivision schoolTimeDistrictSubDivisionOfResidence = personalData .getSchoolTimeDistrictSubDivisionOfResidence(); form.setSchoolTimeDistrictSubdivisionOfResidence(schoolTimeDistrictSubDivisionOfResidence); if (getSchoolTimePhysicalAddress(person) != null) { PhysicalAddress addressSchoolTime = getSchoolTimePhysicalAddress(person); form.setSchoolTimeAddress(addressSchoolTime.getAddress()); form.setSchoolTimeAreaCode( addressSchoolTime.getAreaCode() + " " + addressSchoolTime.getAreaOfAreaCode()); form.setSchoolTimeArea(addressSchoolTime.getArea()); form.setSchoolTimeParishOfResidence(Parish.findByName(schoolTimeDistrictSubDivisionOfResidence, addressSchoolTime.getParishOfResidence()).orElse(null)); } if (personUl != null) { form.setSchoolTimeResidenceType(personUl.getDislocatedResidenceType()); form.setOtherSchoolTimeResidenceType(personUl.getOtherDislocatedResidenceType()); } } model.addAttribute("residenceInformationForm", form); } }
From source file:org.jasig.portlet.calendar.mvc.controller.EditUserHttpICalController.java
/** * Show the Calendar editing form/*from w ww .j a v a 2s. c o m*/ * * @param request * @param model * @return */ @RequestMapping(params = "action=editUrl") public String showHttpCalendarForm(RenderRequest request, Model model) { if (!model.containsAttribute(FORM_NAME)) { model.addAttribute(FORM_NAME, getHttpCalendarForm(request)); } return "/editCalendarUrl"; }