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:es.ucm.fdi.dalgs.group.web.GroupController.java

/**
 * Methods for modifying activities/*from w  w  w.  j  ava  2s  . com*/
 */

@RequestMapping(value = "/academicTerm/{academicId}/course/{courseId}/group/{groupId}/modify.htm", method = RequestMethod.GET)
public String modifyGroupGET(@PathVariable("academicId") Long id_academic,
        @PathVariable("courseId") Long id_course, @PathVariable("groupId") Long id_group, Model model)
        throws ServletException {

    model.addAttribute("courseId", id_course);

    model.addAttribute("valueButton", "Modify");

    if (!model.containsAttribute("group")) {
        Group p = serviceGroup.getGroup(id_group, id_course, id_academic, false).getSingleElement();
        model.addAttribute("group", p);

    }
    model.addAttribute("typeform", "form.modify");
    return "group/form";
}

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

@RequestMapping(value = "/add", method = RequestMethod.POST)
@RequireHardLogIn//from   w ww. j  a v  a 2s.  c  o m
public String addNewPermission(@Valid final B2BPermissionTypeSelectionForm b2BPermissionTypeSelectionForm,
        final BindingResult bindingResult, final Model model) throws CMSItemNotFoundException {
    if (bindingResult.hasErrors()) {
        model.addAttribute(b2BPermissionTypeSelectionForm);
        GlobalMessages.addErrorMessage(model, "form.global.error");
        return getSelectPermissionTypePage(model);
    }

    if (!model.containsAttribute("b2BPermissionForm")) {
        final B2BPermissionForm b2BPermissionForm = new B2BPermissionForm();
        final B2BPermissionTypeEnum permissionTypeEnum = B2BPermissionTypeEnum
                .valueOf(b2BPermissionTypeSelectionForm.getB2BPermissionType());
        final B2BPermissionTypeData b2BPermissionTypeData = b2bPermissionFacade
                .getB2BPermissionTypeDataForPermission(permissionTypeEnum);
        b2BPermissionForm.setB2BPermissionTypeData(b2BPermissionTypeData);
        b2BPermissionForm.setParentUnitName(b2bUnitFacade.getParentUnit().getUid());
        b2BPermissionForm.setPermissionType(b2BPermissionTypeData.getName());
        model.addAttribute(b2BPermissionForm);
    }
    return getAddPermissionPage(model);
}

From source file:cn.guoyukun.spring.jpa.plugin.web.controller.BaseTreeableController.java

@RequestMapping(value = "{parent}/appendChild", method = RequestMethod.GET)
public String appendChildForm(@PathVariable("parent") M parent, Model model) {

    if (permissionList != null) {
        permissionList.assertHasCreatePermission();
    }/*from w w w  .  j  a va2  s. c  om*/

    setCommonData(model);
    if (!model.containsAttribute("child")) {
        model.addAttribute("child", newModel());
    }

    model.addAttribute(Constants.OP_NAME, "?");

    return viewName("appendChildForm");
}

From source file:ru.mystamps.web.controller.SeriesController.java

private void addSeriesSalesFormToModel(Model model) {
    if (!(Features.ADD_PURCHASES_AND_SALES.isActive()
            && SecurityContextUtils.hasAuthority(Authority.ADD_SERIES_SALES))) {
        return;/*from   ww  w .j a  va  2 s. c om*/
    }

    if (!model.containsAttribute("addSeriesSalesForm")) {
        AddSeriesSalesForm addSeriesSalesForm = new AddSeriesSalesForm();
        addSeriesSalesForm.setDate(new Date());
        model.addAttribute("addSeriesSalesForm", addSeriesSalesForm);
    }

    List<EntityWithIdDto> sellers = transactionParticipantService.findAllSellers();
    model.addAttribute("sellers", sellers);

    List<EntityWithIdDto> buyers = transactionParticipantService.findAllBuyers();
    model.addAttribute("buyers", buyers);
}

From source file:com.epam.training.storefront.controllers.pages.payment.PaymentDetailsPageController.java

private SopPaymentDetailsForm getSopPaymentDetailsForm(final Model model) {
    SopPaymentDetailsForm sopPaymentDetailsForm = new SopPaymentDetailsForm();
    if (model.containsAttribute("sopPaymentDetailsForm")) {
        sopPaymentDetailsForm = (SopPaymentDetailsForm) model.asMap().get("sopPaymentDetailsForm");
    }//from ww  w  .j  av a2  s .c  o m

    return sopPaymentDetailsForm;
}

From source file:om.edu.squ.squportal.portlet.dps.registration.dropw.controller.DropWithWController.java

/**
 * //from   ww w  .ja  va 2 s  . co m
 * method name  : studentWelcome
 * @param request
 * @param model
 * @param locale
 * @return
 * DropWithWController
 * return type  : String
 * 
 * purpose      :
 *
 * Date          :   Mar 27, 2017 4:29:58 PM
 * @throws NotCorrectDBRecordException 
 */
private String studentWelcome(PortletRequest request, Model model, Locale locale)
        throws NotCorrectDBRecordException {
    DropCourseModel dropCourseModel = null;
    List<DropWDTO> dropWDTOs = null;
    Gson gson = new Gson();

    User user = dpsServiceDao.getUser(request);
    Student student = dpsServiceDao.getStudent(user.getUserId(), null, locale);

    if (!model.containsAttribute("dropCourseModel")) {
        dropCourseModel = new DropCourseModel();
    }

    model.addAttribute("dropCourseModel", dropCourseModel);
    model.addAttribute("isRuleStudentComplete",
            dropWService.isRuleStudentComplete(student.getAcademicDetail().getStudentNo(),
                    student.getAcademicDetail().getStdStatCode(), null, null));
    model.addAttribute("courseList", dropWService.getCourseList(student, locale));
    model.addAttribute("dropWDTOs", gson.toJson(dropWService.getDropWCourses(student, locale)));
    return "/registration/dropWithW/student/welcomeDropWithWStudent";
}

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

@RequestMapping(value = "/resetpassword", method = RequestMethod.GET)
@RequireHardLogIn//from  w  w w .jav a2s .c om
public String updatePassword(@RequestParam("user") final String user, final Model model)
        throws CMSItemNotFoundException {
    if (!model.containsAttribute("customerResetPasswordForm")) {
        final CustomerResetPasswordForm customerResetPasswordForm = new CustomerResetPasswordForm();
        customerResetPasswordForm.setUid(user);
        model.addAttribute("customerResetPasswordForm", customerResetPasswordForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserDetailsBreadcrumb(user);
    breadcrumbs.add(new Breadcrumb(
            String.format("/my-company/organization-management/manage-users/restpassword?user=%s",
                    urlEncode(user)),
            getMessageSource().getMessage("text.company.manageusers.restpassword.breadcrumb",
                    new Object[] { user }, "Reset Password {0}  User ", getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUserResetPasswordPage;
}

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

@RequestMapping(value = "/resetpassword", method = RequestMethod.GET)
@RequireHardLogIn//  w w w  .  ja v a 2 s . co m
public String updatePassword(@RequestParam("user") final String user, final Model model)
        throws CMSItemNotFoundException {
    if (!model.containsAttribute("customerResetPasswordForm")) {
        final CustomerResetPasswordForm customerResetPasswordForm = new CustomerResetPasswordForm();
        customerResetPasswordForm.setUid(user);
        model.addAttribute("customerResetPasswordForm", customerResetPasswordForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs = myCompanyBreadcrumbBuilder.createManageUserDetailsBreadcrumb(user);
    breadcrumbs.add(new Breadcrumb(
            String.format("/my-company/organization-management/manage-users/restpassword?user=%s",
                    urlEncode(user)),
            getMessageSource().getMessage("text.company.manageusers.restpassword.breadcrumb",
                    new Object[] { user }, "Reset Password {0}  User ", getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS,
            ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW);
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManageUserResetPasswordPage;
}

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

@RequestMapping(value = "/status-in-use", method = RequestMethod.POST)
public String setCarStatusInUse(@RequestParam("employeeId") Long employeeId,
        @RequestParam("licensePlate") String licensePlate, Model model) {
    if (employeeId == null) {
        model.addAttribute("error", "Employee id must be given.");
    }//from ww  w.  jav a2  s.c om

    RdEmployee employee = employeeService.findRdEmployee(employeeId);

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

    try {
        employeeService.setEmployeeCarInUse(employee, licensePlate);
    } catch (IllegalArgumentException e) {
        model.addAttribute("error", e.getMessage());
    }

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

    return "redirect:" + fromMappingName("ECMC#viewEmployeeCar").arg(0, employee.getId()).build();
}

From source file:com.google.code.trapo.controller.ForumControllerTests.java

@Test
public void should_find_a_forum_by_name() {

    Forum forum = forum();/*w w  w. j a v  a2 s  .com*/
    Model model = model();

    ForumRepository repository = mock(ForumRepository.class);
    when(repository.byName("my new forum")).thenReturn(forum);

    ForumsController controller = controllerWith(repository);
    controller.setTopicsRepository(mock(TopicRepository.class));
    controller.show("my new forum", model);

    assertThat(model.containsAttribute("forum"), is(true));
}