Java Code Examples for org.springframework.ui.ModelMap#containsKey()

The following examples show how to use org.springframework.ui.ModelMap#containsKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 2
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute(name="myCommand", binding=true) TestBean tb,
		BindingResult errors, ModelMap model) {

	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 3
Source File: MailinglistController.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@RequestMapping("/{id:\\d+}/view.action")
public String view(ComAdmin admin, @PathVariable int id, ModelMap model) throws Exception {
	if (id == 0) {
		return "redirect:/mailinglist/create.action";
	}

	MailinglistForm form = null;
	if (model.containsKey("mailinglistForm")) {
		form = (MailinglistForm) model.get("mailinglistForm");
	} else {
		Mailinglist mailinglist = mailinglistService.getMailinglist(id, admin.getCompanyID());
		if (Objects.nonNull(mailinglist)) {
			form = conversionService.convert(mailinglist, MailinglistForm.class);
		}
	}

	if (form == null) {
		form = new MailinglistForm();
	} else {
		RecipientProgressStatisticDto statistic = null;
		if (model.containsAttribute("statisticParams")) {
			statistic = (RecipientProgressStatisticDto) model.get("statisticParams");
		} else {
			statistic = form.getStatistic();
		}

		loadStatistics(admin, statistic, form, model);
		userActivityLogService.writeUserActivityLog(admin, "mailing list view", getDescription(form));
	}

	model.addAttribute("mailinglistForm", form);

	return "mailinglist_view";
}
 
Example 4
Source File: ServletAnnotationControllerHandlerMethodTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 5
Source File: ServletAnnotationControllerHandlerMethodTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute(name="myCommand", binding=true) TestBean tb,
		BindingResult errors, ModelMap model) {

	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 6
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@RequestMapping("VIEW")
@RenderMapping
public String myHandle(@ModelAttribute("myCommand")TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 7
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@RequestMapping("VIEW")
@RenderMapping
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 8
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@RequestMapping("VIEW")
@RenderMapping
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myOtherView";
}
 
Example 9
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@RequestMapping("VIEW")
public String myHandle(@ModelAttribute("myCommand")TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 10
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@RequestMapping("VIEW")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 11
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@RequestMapping("VIEW")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myOtherView";
}
 
Example 12
Source File: ServletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}
 
Example 13
Source File: ServletAnnotationControllerHandlerMethodTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/myPath.do")
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
	FieldError error = errors.getFieldError("age");
	assertNotNull("Must have field error for age property", error);
	assertEquals("value2", error.getRejectedValue());
	if (!model.containsKey("myKey")) {
		model.addAttribute("myKey", "myValue");
	}
	return "myView";
}