Example usage for org.springframework.ui Model containsAttribute

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

Introduction

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

Prototype

boolean containsAttribute(String attributeName);

Source Link

Document

Does this model contain an attribute of the given name?

Usage

From source file:de.hybris.platform.commerceorgaddon.controllers.pages.MyCompanyPageController.java

public String editUser(final String user, final Model model) throws CMSItemNotFoundException {
    List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserDetailsBreadcrumb(user);
    if (!model.containsAttribute("b2BCustomerForm")) {
        final CustomerData customerData = b2bUserFacade.getCustomerForUid(user);
        final B2BCustomerForm b2bCustomerForm = new B2BCustomerForm();
        b2bCustomerForm.setUid(customerData.getUid());
        b2bCustomerForm.setTitleCode(customerData.getTitleCode());
        b2bCustomerForm.setFirstName(customerData.getFirstName());
        b2bCustomerForm.setLastName(customerData.getLastName());
        b2bCustomerForm.setEmail(customerData.getDisplayUid());
        b2bCustomerForm/*  www. j a v  a2s. co m*/
                .setParentB2BUnit(b2bUserFacade.getParentUnitForCustomer(customerData.getUid()).getUid());
        b2bCustomerForm.setActive(customerData.isActive());
        b2bCustomerForm.setApproverGroups(customerData.getApproverGroups());
        b2bCustomerForm.setApprovers(customerData.getApprovers());
        b2bCustomerForm.setRoles(customerData.getRoles());
        model.addAttribute(b2bCustomerForm);
    }

    model.addAttribute("titleData", getUserFacade().getTitles());
    model.addAttribute("roles", populateRolesCheckBoxes(b2bUserGroupFacade.getUserGroups()));

    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));

    if (model.containsAttribute("newUserEdit")) {
        breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserBreadcrumb();
        breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-users/create",
                getMessageSource().getMessage("text.company.organizationManagement.createuser", null,
                        getI18nService().getCurrentLocale()),
                null));
    } else {
        breadcrumbs.add(new Breadcrumb(
                String.format("/my-company/organization-management/manage-users/edit?user=%s", urlEncode(user)),
                getMessageSource().getMessage("text.company.manageusers.edit", new Object[] { user },
                        "Edit {0} User", getI18nService().getCurrentLocale()),
                null));
    }
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS,
            ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW);
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUserAddEditFormPage;
}

From source file:com.realdolmen.rdfleet.webmvc.controllers.fleet.EmployeeCarManagementController.java

private String setCarStatusTo(Long employeeId, Model model, CarStatus status) {
    if (employeeId == null) {
        model.addAttribute("error", "Employee id must be given.");
    }/*from  ww  w .j  a  va2  s .co m*/

    RdEmployee employee = employeeService.findRdEmployee(employeeId);

    if (employee == null) {
        model.addAttribute("error", "Employee was not found.");
        return "fleet/employee.list";
    }

    try {
        switch (status) {
        case REMOVED:
            employeeService.setEmployeeCarRemoved(employee);
            break;
        case NOT_USED:
            employeeService.setEmployeeCarInFreePool(employee);
            break;
        default:
            throw new IllegalArgumentException("An invalid status was provided.");
        }
    } catch (IllegalArgumentException e) {
        model.addAttribute("error", e.getMessage());
    }

    if (model.containsAttribute("error")) {
        model.addAttribute("employee", employee);
        return "fleet/employee.car.detail";
    }

    return "redirect:" + fromMappingName("REMC#employees").build();
}

From source file:com.jnj.b2b.storefront.controllers.pages.ProductPageController.java

@RequestMapping(value = PRODUCT_CODE_PATH_VARIABLE_PATTERN + "/orderForm", method = RequestMethod.GET)
public String productOrderForm(@PathVariable("productCode") final String productCode, final Model model,
        final HttpServletRequest request, final HttpServletResponse response) throws CMSItemNotFoundException {
    final ProductModel productModel = productService.getProductForCode(productCode);

    updatePageTitle(productModel, model);
    final List<ProductOption> extraOptions = Arrays.asList(ProductOption.VARIANT_MATRIX_BASE,
            ProductOption.VARIANT_MATRIX_PRICE, ProductOption.VARIANT_MATRIX_MEDIA,
            ProductOption.VARIANT_MATRIX_STOCK);
    populateProductDetailForDisplay(productCode, model, request, extraOptions);

    if (!model.containsAttribute(WebConstants.MULTI_DIMENSIONAL_PRODUCT)) {
        return REDIRECT_PREFIX + productModelUrlResolver.resolve(productModel);
    }//from   ww  w .  j av a2  s . co m

    final String metaKeywords = MetaSanitizerUtil.sanitizeKeywords(productModel.getKeywords());
    final String metaDescription = MetaSanitizerUtil.sanitizeDescription(productModel.getDescription());
    setUpMetaData(model, metaKeywords, metaDescription);

    return ControllerConstants.Views.Pages.Product.OrderForm;
}

From source file:cec.easyshop.storefront.controllers.pages.ProductPageController.java

@RequestMapping(value = PRODUCT_CODE_PATH_VARIABLE_PATTERN + "/orderForm", method = RequestMethod.GET)
public String productOrderForm(@PathVariable("productCode") final String productCode, final Model model,
        final HttpServletRequest request, final HttpServletResponse response) throws CMSItemNotFoundException {
    final ProductModel productModel = productService.getProductForCode(productCode);
    updatePageTitle(productModel, model);

    final List<ProductOption> extraOptions = Arrays.asList(ProductOption.VARIANT_MATRIX_BASE,
            ProductOption.VARIANT_MATRIX_PRICE, ProductOption.VARIANT_MATRIX_MEDIA,
            ProductOption.VARIANT_MATRIX_STOCK, ProductOption.URL);
    populateProductDetailForDisplay(productModel, model, request, extraOptions);

    if (!model.containsAttribute(WebConstants.MULTI_DIMENSIONAL_PRODUCT)) {
        return REDIRECT_PREFIX + productModelUrlResolver.resolve(productModel);
    }/*  w w  w. j  a  va2 s .  c om*/

    return ControllerConstants.Views.Pages.Product.OrderForm;
}

From source file:om.edu.squ.squportal.portlet.dps.study.extension.controller.ExtensionStudiesController.java

/**
 * //from w  w  w.j a v a2 s .c om
 * method name  : studentWelcome
 * @param request
 * @param model
 * @param locale
 * @return
 * ExtensionStudiesController
 * return type  : String
 * 
 * purpose      : Student Welcome
 *
 * Date          :   Jan 12, 2017 3:03:12 PM
 * @throws NotCorrectDBRecordException 
 */
private String studentWelcome(PortletRequest request, Model model, Locale locale)
        throws NotCorrectDBRecordException {
    String studentNumber = null;
    String studentStatCode = null;

    String userName = request.getRemoteUser();
    User user = dpsServiceDao.getUser(request);
    Student student = dpsServiceDao.getStudent(user.getUserId(), null, new Locale("en"));

    studentNumber = student.getAcademicDetail().getStudentNo();
    studentStatCode = student.getAcademicDetail().getStdStatCode();

    List<ExtensionDTO> extensions = null;
    if (null == extensionServiceDao.getExtensionsForStudents(studentNumber, studentStatCode, locale)) {

    } else {
        extensions = extensionServiceDao.getExtensionsForStudents(studentNumber, studentStatCode, locale);
    }

    if (!model.containsAttribute("extensionStudentDataModel")) {
        ExtensionStudentDataModel extensionStudentDataModel = new ExtensionStudentDataModel();
        model.addAttribute("extensionStudentDataModel", extensionStudentDataModel);
    }

    model.addAttribute("hasSuperVisor", dpsServiceDao.isSupervisorAvailable(studentNumber, studentStatCode));
    model.addAttribute("student", student);
    model.addAttribute("currYearSem", dpsServiceDao.getCurrentYearSemester(locale));
    model.addAttribute("nextYearSemester", dpsServiceDao.getNextYearSemester(locale));
    model.addAttribute("reasonList", extensionServiceDao.getExtensionReasons(locale));

    model.addAttribute("extenstions", extensions);
    /* TODO for Apply RULE uncomment the following statement */
    model.addAttribute("isRuleStudentComplete", true);
    //model.addAttribute("isRuleStudentComplete", extensionServiceDao.isRuleStudentComplete(student.getAcademicDetail().getStudentNo(),student.getAcademicDetail().getStdStatCode()));

    return "study/extension/student/welcomeExtensionStudent";
}

From source file:com.ctc.storefront.controllers.pages.ProductPageController.java

@RequestMapping(value = PRODUCT_CODE_PATH_VARIABLE_PATTERN + "/orderForm", method = RequestMethod.GET)
public String productOrderForm(@PathVariable("productCode") final String productCode, final Model model,
        final HttpServletRequest request, final HttpServletResponse response) throws CMSItemNotFoundException {
    final List<ProductOption> extraOptions = Arrays.asList(ProductOption.VARIANT_MATRIX_BASE,
            ProductOption.VARIANT_MATRIX_PRICE, ProductOption.VARIANT_MATRIX_MEDIA,
            ProductOption.VARIANT_MATRIX_STOCK, ProductOption.URL);

    final ProductData productData = productFacade.getProductForCodeAndOptions(productCode, extraOptions);
    updatePageTitle(productCode, model);

    populateProductDetailForDisplay(productCode, model, request, extraOptions);

    if (!model.containsAttribute(WebConstants.MULTI_DIMENSIONAL_PRODUCT)) {
        return REDIRECT_PREFIX + productDataUrlResolver.resolve(productData);
    }//w  ww.  ja v a  2  s.c o  m

    return ControllerConstants.Views.Pages.Product.OrderForm;
}

From source file:de.hybris.platform.commerceorgaddon.controllers.pages.B2BUserGroupManagementPageController.java

@RequestMapping(value = "/create", method = RequestMethod.GET)
@RequireHardLogIn//from w  w w .  ja v  a2  s.  c  om
public String createUserGroup(final Model model) throws CMSItemNotFoundException {
    storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserGroupBreadCrumbs();
    breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-usergroups/create",
            getMessageSource().getMessage("text.company.manageUsergroups.createUsergroup.breadcrumb", null,
                    "Create Usergroup ", getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);

    if (!model.containsAttribute("b2BUserGroupForm")) {
        final B2BUnitData unitData = b2bUnitFacade.getParentUnit();
        final B2BUserGroupForm b2BUserGroupForm = new B2BUserGroupForm();
        b2BUserGroupForm.setParentUnit(unitData.getUid());
        model.addAttribute(b2BUserGroupForm);
    }

    model.addAttribute("branchSelectOptions", getBranchSelectOptions(b2bUnitFacade.getBranchNodes()));
    model.addAttribute("unit", b2bUnitFacade.getParentUnit());
    model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS,
            ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW);
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUsergroupCreatePage;
}

From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.B2BUserGroupManagementPageController.java

@RequestMapping(value = "/create", method = RequestMethod.GET)
@RequireHardLogIn//from   w  ww .j av a2s.  c  o  m
public String createUserGroup(final Model model) throws CMSItemNotFoundException {
    storeCmsPageInModel(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MANAGE_USERGROUPS_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserGroupBreadCrumbs();
    breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-usergroups/create",
            getMessageSource().getMessage("text.company.manageUsergroups.createUsergroup.breadcrumb", null,
                    "Create Usergroup ", getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);

    if (!model.containsAttribute("b2BUserGroupForm")) {
        final B2BUnitData unitData = companyB2BCommerceFacade.getParentUnit();
        final B2BUserGroupForm b2BUserGroupForm = new B2BUserGroupForm();
        b2BUserGroupForm.setParentUnit(unitData.getUid());
        model.addAttribute(b2BUserGroupForm);
    }

    model.addAttribute("branchSelectOptions",
            getBranchSelectOptions(this.companyB2BCommerceFacade.getBranchNodes()));
    model.addAttribute("unit", companyB2BCommerceFacade.getParentUnit());
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUsergroupCreatePage;
}

From source file:cec.easyshop.storefront.controllers.pages.CartPageController.java

@SuppressWarnings("boxing")
@ResponseBody//from w  ww  .  ja  v  a  2  s . c  om
@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 (error.getCode().equals("typeMismatch")) {
                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 = "/orderApprovalDetails/"
        + WORKFLOW_ACTION_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
@RequireHardLogIn//from  w ww .  j a v  a  2 s .c o m
public String orderApprovalDetails(@PathVariable("workflowActionCode") final String workflowActionCode,
        final Model model) throws CMSItemNotFoundException {
    try {
        final B2BOrderApprovalData orderApprovalDetails = orderFacade
                .getOrderApprovalDetailsForCode(workflowActionCode);
        model.addAttribute("orderApprovalData", orderApprovalDetails);
        if (!model.containsAttribute("orderApprovalDecisionForm")) {
            model.addAttribute("orderApprovalDecisionForm", new OrderApprovalDecisionForm());
        }

        final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null);
        breadcrumbs.add(new Breadcrumb("/my-account/approval-dashboard", getMessageSource().getMessage(
                "text.account.orderApprovalDashboard", null, getI18nService().getCurrentLocale()), null));
        breadcrumbs.add(new Breadcrumb("#",
                getMessageSource().getMessage("text.account.order.orderBreadcrumb",
                        new Object[] { orderApprovalDetails.getB2bOrderData().getCode() }, "Order {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(ORDER_DETAIL_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORDER_DETAIL_CMS_PAGE));
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.Account.AccountOrderApprovalDetailsPage;
}