List of usage examples for org.springframework.ui Model containsAttribute
boolean containsAttribute(String attributeName);
From source file:controllers.admin.SelfUserController.java
@RequestMapping(method = RequestMethod.GET) public String self(@CurrentUser User user, Model model) { if (!model.containsAttribute(BINDING_RESULT_NAME)) { model.addAttribute(ATTRIBUTE_NAME, user); }//from www. j a v a 2 s . c om return "admin/user/self"; }
From source file:controllers.admin.UsersController.java
@GetMapping("/edit/{userId}") public String edit(@PathVariable Long userId, Model model) { if (!model.containsAttribute(BINDING_RESULT_NAME)) { List<Role> allRoles = rolesRepository.findAll(); User user = userService.findById(userId); if (user == null) throw new UserNotFoundException(); model.addAttribute(ATTRIBUTE_ROLES_NAME, allRoles); model.addAttribute(ATTRIBUTE_USER_NAME, user); }//from w w w. j a v a2s . com return "admin/user/edit"; }
From source file:com.mtt.myapp.operation.AnnouncementControllerTest.java
@Test public void testOpenAnnouncement() { Model model = new ExtendedModelMap(); controller.open(model);/*w w w. j a va 2 s . c o m*/ assertThat(model.containsAttribute("content")).isFalse(); }
From source file:com.onclave.testbench.simpleForm.SimpleFormController.java
@RequestMapping(value = "/submitForm", method = RequestMethod.POST) public String showFormContents(@ModelAttribute("studentForm") @Validated StudentPOJO student, BindingResult result, Model model) { String returnView = "/form/result"; if (!model.containsAttribute("studentForm")) { model.addAttribute("studentForm", student); }/*from w w w .j a v a 2s.co m*/ if (result.hasErrors()) { returnView = "/form/showForm"; } else { model.addAttribute("studentForm", student); } return returnView; }
From source file:org.ngrinder.operation.AnnouncementControllerTest.java
@Test public void testOpenAnnouncement() { Model model = new ExtendedModelMap(); controller.open(model);//from w w w .j a v a 2 s.c o m assertThat(model.containsAttribute("content"), is(true)); }
From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.SasBaseController.java
@ModelAttribute protected void addModelProperties(Model model) { if (!model.containsAttribute(INFO_MESSAGES)) { model.addAttribute(INFO_MESSAGES, new ArrayList<String>()); }// w w w.j a va2 s .c om if (!model.containsAttribute(WARNING_MESSAGES)) { model.addAttribute(WARNING_MESSAGES, new ArrayList<String>()); } if (!model.containsAttribute(ERROR_MESSAGES)) { model.addAttribute(ERROR_MESSAGES, new ArrayList<String>()); } // Add here more attributes to the Model // model.addAttribute(<attr1Key>, <attr1Value>); // .... }
From source file:org.cloudfoundry.identity.uaa.login.ProfileControllerTests.java
public void testGet() { 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.get(model);//from w w w . j av a 2 s .c o m assertTrue(model.containsAttribute("links")); assertTrue(model.containsAttribute("approvals")); }
From source file:org.jasig.portlet.ClassifiedsPortlet.web.SubmitConfigFormController.java
@RequestMapping(params = "action=editConfig") public String setupForm(@RequestParam(value = "id", required = false) Long id, Model model, PortletRequest request) {/*from w w w . ja v a2 s. c o m*/ if (!model.containsAttribute("config")) { Config config = new Config(); List<Config> configList = this.configService.getConfig(); if (configList.size() == 0) { model.addAttribute("config", config); } else { config = (Config) configList.get(0); model.addAttribute("config", config); } } return "submitConfigForm"; }
From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.SasBaseController.java
protected String redirect(String destinationAction, Model model, RedirectAttributes redirectAttributes) { if (model.containsAttribute(INFO_MESSAGES)) { redirectAttributes.addFlashAttribute(INFO_MESSAGES, model.asMap().get(INFO_MESSAGES)); }/*from w ww . j av a2s.com*/ if (model.containsAttribute(WARNING_MESSAGES)) { redirectAttributes.addFlashAttribute(WARNING_MESSAGES, model.asMap().get(WARNING_MESSAGES)); } if (model.containsAttribute(ERROR_MESSAGES)) { redirectAttributes.addFlashAttribute(ERROR_MESSAGES, model.asMap().get(ERROR_MESSAGES)); } return "redirect:" + destinationAction; }
From source file:org.ngrinder.operation.AnnouncementControllerTest.java
@Test public void testSaveAnnouncement() { Model model = new ExtendedModelMap(); String content = "My test."; controller.save(model, content);/*from w ww .j a va 2 s . co m*/ assertThat(model.containsAttribute("success"), is(true)); assertThat(service.getOne(), is(content)); assertThat(config.getAnnouncement(), is(content)); }