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:org.duracloud.account.app.controller.AccountUsersControllerTest.java

private void verifyGet(Model model) {
    Assert.assertTrue(model.containsAttribute("account"));
    Assert.assertTrue(model.containsAttribute(AccountUsersController.USERS_KEY));
}

From source file:org.jasig.portlet.ClassifiedsPortlet.web.SubmitCategoryFormController.java

@RequestMapping(params = "action=addCategory")
public String setupForm(@RequestParam(value = "id", required = false) Long id, Model model,
        PortletRequest request) {//from  w w  w. j a v a 2  s.  c  om
    Category category = new Category();

    if (!model.containsAttribute("category")) {
        if (id != null) {
            List<Category> categoryList = this.categoryService.getCategory(id);
            category = (Category) categoryList.get(0);

        }

        model.addAttribute("category", category);
    }
    return "submitCategoryForm";
}

From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java

public void testPostForUpdate() {
    controller.setLinks(Collections.singletonMap("foo", "http://example.com"));
    Mockito.when(restTemplate.getForObject(approvalsUri, Set.class))
            .thenReturn(Collections.singleton(Collections.singletonMap("clientId", "foo")));
    Model model = new ExtendedModelMap();
    controller.post(Collections.singleton("read"), "", null, "foo", model);
    assertTrue(model.containsAttribute("links"));
    assertTrue(model.containsAttribute("approvals"));
}

From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java

public void testPostForDelete() {
    controller.setLinks(Collections.singletonMap("foo", "http://example.com"));
    Mockito.when(restTemplate.getForObject(approvalsUri, Set.class))
            .thenReturn(Collections.singleton(Collections.singletonMap("clientId", "foo")));
    Model model = new ExtendedModelMap();
    controller.post(Collections.singleton("read"), null, "", "foo", model);
    assertTrue(model.containsAttribute("links"));
    assertTrue(model.containsAttribute("approvals"));
}

From source file:com.mtt.myapp.operation.AnnouncementControllerTest.java

@Test
public void testSaveAnnouncement() {
    Model model = new ExtendedModelMap();
    String content = "system=System test.\nuser=User test.";
    controller.save(model, content);/* w ww  .jav a  2  s .  c o  m*/

    assertThat(model.containsAttribute("success")).isTrue();

    assertThat(service.getSysAnnouncement()).isEqualTo("System test.");
    assertThat(service.getUserAnnouncement()).isEqualTo("User test.");
}

From source file:org.jasig.portlet.calendar.mvc.controller.EditCalendarDefinitionController.java

@RequestMapping(params = "action=createCalendarDefinition")
public String showNewCalendarDefinitionForm(PortletRequest request, Model model) {
    if (!model.containsAttribute(FORM_NAME)) {
        final CalendarDefinitionForm form = new CalendarDefinitionForm();
        model.addAttribute(FORM_NAME, form);
    }//from  w ww . j a v  a 2  s . c o m
    model.addAttribute("adapters", adapters);
    return "/createCalendarDefinition";
}

From source file:org.jasig.portlet.announcements.controller.AdminRoleSetController.java

@RequestMapping(params = "action=addMembers")
public String showForm(@RequestParam("topicId") Long topicId, @RequestParam("groupKey") String groupKey,
        Model model) throws PortletException {

    if (!model.containsAttribute("selection")) {
        Topic topic = announcementService.getTopic(topicId);
        Set<String> group = topic.getGroup(groupKey);

        model.addAttribute("selection", new RoleSelection(group));
        model.addAttribute("roles", groupService.getAllRolesFromGroupSet(topic.getGroup(groupKey)));
        model.addAttribute(topic);/*from  www . j  a v a2s .  co  m*/

    }

    model.addAttribute("groupKey", groupKey);

    return "addMembers";
}

From source file:com.opencredo.portlet.BooksController.java

@RequestMapping(params = "action=editBook")
// render phase/*w  w  w .  j a  v  a 2  s .c  o  m*/
public String showEditBookForm(@RequestParam("book") Integer id, Model model) {
    if (!model.containsAttribute("book")) {
        model.addAttribute("book", bookService.getBook(id));
    }
    return "bookEdit";
}

From source file:com.opencredo.portlet.BooksController.java

@RequestMapping(params = "action=addBook")
// render phase/*w  ww.  j ava 2 s  .c om*/
public String showAddBookForm(Model model) {
    if (!model.containsAttribute("book")) {
        model.addAttribute("book", new Book());
        model.addAttribute("page", 0);
    }
    return "bookAdd";
}

From source file:org.jasig.portlet.ClassifiedsPortlet.web.SubmitHeadingFormController.java

@RequestMapping(params = "action=addHeading")
public String setupForm(@RequestParam(value = "id", required = false) Long id, Model model,
        PortletRequest request) {/*from ww  w. j a v  a2s .  c  o m*/
    Heading heading = new Heading();

    if (!model.containsAttribute("heading")) {

        if (id != null) {
            List<Heading> headingList = this.headingService.getHeading(id);
            heading = (Heading) headingList.get(0);
        }
        model.addAttribute("heading", heading);
    }

    return "submitHeadingForm";
}