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:com.ebook.storefront.controllers.pages.CheckoutController.java

private void processEmailAddress(final Model model, final OrderData orderDetails) {
    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);/*from   w  w  w  .  j  a v a  2  s.c  o m*/
        model.addAttribute(guestRegisterForm);
    } else {
        uid = orderDetails.getUser().getUid();
    }
    model.addAttribute("email", uid);
}

From source file:no.dusken.barweb.admin.InvoiceControllerTest.java

@Test
public void testGenerateInvoicePdf() throws Exception {
    Model m = new ExtendedModelMap();
    String view = controller.generateInvoicePdf(12L, m);
    assertEquals("Wrong view", "invoiceview", view);
    assertTrue("Entity missing", m.containsAttribute("invoice"));
    assertTrue("Entity missing", m.containsAttribute("persons"));
    assertTrue("Entity missing", m.containsAttribute("gjeng"));
}

From source file:es.ucm.fdi.dalgs.module.web.ModuleController.java

@RequestMapping(value = "/degree/{degreeId}/module/{moduleId}/modify.htm", method = RequestMethod.GET)
public String modifyModuleGET(@PathVariable("degreeId") Long id_degree,
        @PathVariable("moduleId") Long id_module, Model model) throws ServletException {

    // ModelAndView model = new ModelAndView();
    if (!model.containsAttribute("module")) {
        Module p = serviceModule.getModule(id_module, id_degree).getSingleElement();
        model.addAttribute("module", p);
    }/*from w ww  .  ja  v a 2 s  .co  m*/
    model.addAttribute("valueButton", "Modify");
    model.addAttribute("typeform", "form.modify");

    return "module/form";
}

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

@RequestMapping(value = "/add", method = RequestMethod.GET)
@RequireHardLogIn// w w  w .ja v a 2  s .c o m
public String getAddBudgetPage(final Model model) throws CMSItemNotFoundException {
    if (!model.containsAttribute("b2BBudgetForm")) {
        final B2BBudgetForm b2BBudgetForm = new B2BBudgetForm();
        final B2BUnitData b2BUnitData = companyB2BCommerceFacade.getParentUnit();
        b2BBudgetForm.setParentB2BUnit(b2BUnitData.getUid());
        model.addAttribute(b2BBudgetForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageBudgetsBreadCrumbs();
    breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-budgets/update",
            getMessageSource().getMessage("text.company.budget.addPage", null,
                    getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageBudgetsAddPage;
}

From source file:rzd.vivc.documentexamination.controller.DocumentController.java

/**
*  GET ? c path parameter  /documents   ???
*  ?  id   document -  ??  ??//  www  .j  a  v a  2  s. co  m
* ?    ? view ?? document,   ? ?
* ??
*
* @param documentID id 
* @param model  ?  ? view
* @return ?? 
*/
@RequestMapping(value = "/{documentID}", method = RequestMethod.GET)
//value="documentID"  ?, ?      value  requestMapping ?
public String document(@PathVariable(value = "documentID") long documentID, Model model) {
    //       ?   ? ??
    if (!model.containsAttribute("document")) {
        Document findOne = documentRepository.findOne(documentID);
        model.addAttribute(findOne);
        model.addAttribute("link", fileSavingService.getFileLink(findOne.getFile()));
    } else {
        model.addAttribute("link",
                fileSavingService.getFileLink(((Document) model.asMap().get("document")).getFile()));
    }
    return "document";
}

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

@RequestMapping(value = "/add", method = RequestMethod.GET)
@RequireHardLogIn/*from  w ww.  ja v  a 2 s .  co  m*/
public String getAddBudgetPage(final Model model) throws CMSItemNotFoundException {
    if (!model.containsAttribute("b2BBudgetForm")) {
        final B2BBudgetForm b2BBudgetForm = new B2BBudgetForm();
        final B2BUnitData b2BUnitData = b2bUnitFacade.getParentUnit();
        b2BBudgetForm.setParentB2BUnit(b2BUnitData.getUid());
        model.addAttribute(b2BBudgetForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageBudgetsBreadCrumbs();
    breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-budgets/update",
            getMessageSource().getMessage("text.company.budget.addPage", null,
                    getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS,
            ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW);
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageBudgetsAddPage;
}

From source file:com.web.mavenproject6.controller.UserController.java

@RequestMapping("/public/signup")
public String create(Model model) {

    if (!model.containsAttribute("user")) {
        model.addAttribute("user", new UserForm());
    }//from  w w w  .  java2 s. c  o m

    if (reCaptcha != null) {
        model.addAttribute("recaptcha", reCaptcha.createRecaptchaHtml(null, null));
    }

    return "thy/public/signup";
}

From source file:no.dusken.barweb.admin.InvoiceControllerTest.java

@Test
public void testDeleteInvoice() throws Exception {
    Model m = new ExtendedModelMap();
    String view = controller.deleteInvoice(12L, m);
    assertEquals("Wrong view", "no/dusken/barweb/common/deleted", view);
    assertTrue("Entity missing", m.containsAttribute("entity"));
    verify(invoiceTransaksjonService).deleteInvoiceUpdateTransaksjons(any(Invoice.class), any(List.class));
}

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

@RequestMapping(value = "/add", method = RequestMethod.GET)
@RequireHardLogIn//w w w.  j  a v  a  2  s .  co m
public String getSelectPermissionTypePage(final Model model) throws CMSItemNotFoundException {
    if (!model.containsAttribute("b2BPermissionTypeSelectionForm")) {
        model.addAttribute(new B2BPermissionTypeSelectionForm());
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManagePermissionsBreadcrumb();
    if (ResponsiveUtils.isResponsive()) {
        breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-permissions/add",
                getMessageSource().getMessage("text.company.managePermissions.create.new.permission", null,
                        getI18nService().getCurrentLocale()),
                null));
    } else {
        breadcrumbs.add(new Breadcrumb("/my-company/organization-management/manage-permissions/add",
                getMessageSource().getMessage("text.company.managePermissions.create.step1.page", null,
                        getI18nService().getCurrentLocale()),
                null));
    }
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS,
            ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW);
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManagePermissionTypeSelectPage;

}

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

protected void processEmailAddress(final Model model, final OrderData orderDetails) {
    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);//from  ww w.j  a va 2 s  .  c o  m
        model.addAttribute(guestRegisterForm);
    } else {
        uid = orderDetails.getUser().getUid();
    }
    model.addAttribute("email", uid);
}