From a7d77d95cf8f3ba8d6eb44146c72878cac1bd10a Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 12 Nov 2009 22:43:22 +0000 Subject: [PATCH] fixed incorrect example and JSF reference git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2419 50f2f4bb-b051-0410-bef5-90022cba6387 --- spring-framework-reference/src/mvc.xml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 49e6b4d02f0..1abfdb5ff67 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -676,7 +676,7 @@ public class HelloWorldController { for a specific HTTP method request method ("GET"/"POST") or specific HTTP request parameters. - The following example shows a controller in a JSF application + The following example shows a controller in a Spring MVC application that uses this annotation: @Controller @@ -691,19 +691,13 @@ public class AppointmentsController { } @RequestMapping(method = RequestMethod.GET) - public Appointments get() { + public Map<String, Appointment> get() { return appointmentBook.getAppointmentsForToday(); } @RequestMapping(value="/{day}", method = RequestMethod.GET) - public void getForDay(@PathVariable Date day, ExternalContext context) { - Appointments appts = appointmentBook.getAppointmentsForDay(day); - context.getModel().addAttribute(appts); - context.selectView("appointments"); - if (context.isAjaxRequest()) { - //could activate a ViewHelper for component associated with main - context.renderFragment("main"); - } + public Map<String, Appointment> getForDay(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date day, Model model) { + return appointmentBook.getAppointmentsForDay(day); } @RequestMapping(value="/new", method = RequestMethod.GET) @@ -712,8 +706,11 @@ public class AppointmentsController { } @RequestMapping(method = RequestMethod.POST) - public String post(AppointmentForm form) { - appointmentBook.createAppointment(form); + public String add(@Valid AppointmentForm appointment, BindingResult result) { + if (result.hasErrors()) { + return "appointments/new"; + } + appointmentBook.addAppointment(appointment); return "redirect:/appointments"; } }