Example usage for org.springframework.ui Model addAllAttributes

List of usage examples for org.springframework.ui Model addAllAttributes

Introduction

In this page you can find the example usage for org.springframework.ui Model addAllAttributes.

Prototype

Model addAllAttributes(Map<String, ?> attributes);

Source Link

Document

Copy all attributes in the supplied Map into this Map .

Usage

From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java

@RequestMapping(value = "/create-account", method = RequestMethod.POST)
public String createCustomer(final Model model, @RequestParam("customerId") final String customerId,
        @RequestParam("customerName") final String customerName) {
    String redirectTo = ASSISTED_SERVICE_COMPONENT;
    try {//from   w w  w . j a v  a  2 s.  c o m
        assistedServiceFacade.createCustomer(customerId, customerName);
        // customerId is lower cased when user registered using customer account service
        final String customerIdLowerCased = customerId.toLowerCase();
        final CartModel sessionCart = cartService.getSessionCart();
        if (sessionCart != null && userService.isAnonymousUser(sessionCart.getUser())
                && CollectionUtils.isNotEmpty(sessionCart.getEntries())) {
            // if there's already an anonymous cart with entries - bind it to customer
            bindCart(customerIdLowerCased, null, model);
            redirectTo = emulateCustomer(model, customerIdLowerCased, null,
                    cartService.getSessionCart().getCode());
        } else {
            redirectTo = emulateCustomer(model, customerIdLowerCased, null, null);
        }
        try {
            subscriptionFacadeWrapper.updateProfile(new HashMap<String, String>());
        } catch (final Exception ex) {
            LOG.error("Subscription profile updating failed", ex);
            throw new AssistedServiceException("Subscription profile updating failed", ex);
        }
    } catch (final AssistedServiceException e) {
        if (e.getMessage() != null && e.getMessage().toLowerCase().contains("duplicate")) {
            model.addAttribute(ASM_MESSAGE_ATTRIBUTE, "asm.createCustomer.duplicate.error");
            model.addAttribute(ASM_ALERT_CLASS, "ASM_alert_customer ASM_alert_create_new");
        } else {
            model.addAttribute(ASM_MESSAGE_ATTRIBUTE, "asm.createCustomer.error");
        }
        model.addAttribute("customerId", this.encodeValue(customerId));
        model.addAttribute("customerName", this.encodeValue(customerName + ", " + customerId));
        LOG.debug(e.getMessage(), e);
    }
    model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes());
    return redirectTo;
}

From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java

@RequestMapping(value = "/personify-stop", method = RequestMethod.POST)
public String endEmulateCustomer(final Model model) {
    authoritiesManager.restoreInitialAuthorities();
    assistedServiceFacade.stopEmulateCustomer();
    refreshSpringSecurityToken();/*from   ww w  .  ja  v  a 2  s  .co  m*/
    model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes());
    model.addAttribute(ASM_REDIRECT_URL_ATTRIBUTE, "/");
    return ASSISTED_SERVICE_COMPONENT;
}

From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java

@RequestMapping(value = "/bind-cart", method = RequestMethod.POST)
public String bindCart(@RequestParam(value = "customerId", required = false) final String customerId,
        @RequestParam(value = "cartId", required = false) final String cartId, final Model model) {
    try {/*from   w w w.ja va  2 s.  c o  m*/
        assistedServiceFacade.bindCustomerToCart(customerId, cartId);
        refreshSpringSecurityToken();
        model.addAttribute(ASM_REDIRECT_URL_ATTRIBUTE, "/");
    } catch (final AssistedServiceException e) {
        model.addAttribute(ASM_MESSAGE_ATTRIBUTE, e.getMessage());
        model.addAttribute("customerId", this.encodeValue(customerId));
        LOG.debug(e.getMessage(), e);
    }
    model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes());
    return ASSISTED_SERVICE_COMPONENT;
}

From source file:de.hybris.platform.assistedservicestorefront.controllers.cms.AssistedServiceComponentController.java

@RequestMapping(value = "/refresh", method = RequestMethod.POST)
public String refresh(final Model model) {
    model.addAllAttributes(assistedServiceFacade.getAssistedServiceSessionAttributes());
    return ASSISTED_SERVICE_COMPONENT;
}

From source file:org.cloudfoundry.identity.uaa.home.HomeController.java

protected void populateBuildAndLinkInfo(Model model) {
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("links", getLinksInfo());
    model.addAllAttributes(attributes);
    model.addAttribute("links", getLinks());
}

From source file:org.davidmendoza.irsvped.web.ProfileController.java

@RequestMapping(method = RequestMethod.GET)
public String profile(Model model, Principal principal, @RequestParam(required = false) Integer max,
        @RequestParam(required = false) Integer offset, @RequestParam(required = false) String filter,
        @RequestParam(required = false) Long page, @RequestParam(required = false) String sort,
        @RequestParam(required = false) String order) {

    Map<String, Object> params = new HashMap<>();
    if (max != null) {
        params.put("max", max);
        if (offset != null) {
            params.put("offset", offset);
        }//from w w w . ja v a2s  .c  o m
    } else {
        params.put("max", 10);
        params.put("offset", 0);
    }

    if (StringUtils.isNotBlank(filter)) {
        params.put("filter", filter);
    }

    if (StringUtils.isNotBlank(sort)) {
        params.put("sort", sort);
    } else {
        params.put("sort", "name");
    }

    if (StringUtils.isNotBlank(order)) {
        params.put("order", order);
    } else {
        params.put("order", "asc");
    }
    params.put("order2", params.get("order"));

    params.put("mine", Boolean.TRUE);
    params.put("principal", principal.getName());

    params = eventService.list(params);

    this.paginate(params, model, page);

    model.addAllAttributes(params);

    return "home/profile";
}