Skip to content

Commit 4e35c59

Browse files
author
Keith Donald
committed
fixed incorrect example and JSF reference
1 parent 3361de3 commit 4e35c59

File tree

1 file changed

+9
-12
lines changed
  • spring-framework-reference/src

1 file changed

+9
-12
lines changed

spring-framework-reference/src/mvc.xml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public class HelloWorldController {
676676
for a specific HTTP method request method ("GET"/"POST") or specific
677677
HTTP request parameters.</para>
678678

679-
<para>The following example shows a controller in a JSF application
679+
<para>The following example shows a controller in a Spring MVC application
680680
that uses this annotation:</para>
681681

682682
<programlisting language="java">@Controller
@@ -691,19 +691,13 @@ public class AppointmentsController {
691691
}
692692

693693
<emphasis role="bold">@RequestMapping(method = RequestMethod.GET)</emphasis>
694-
public Appointments get() {
694+
public Map&lt;String, Appointment&gt; get() {
695695
return appointmentBook.getAppointmentsForToday();
696696
}
697697

698698
<emphasis role="bold">@RequestMapping(value="/{day}", method = RequestMethod.GET)</emphasis>
699-
public void getForDay(@PathVariable Date day, ExternalContext context) {
700-
Appointments appts = appointmentBook.getAppointmentsForDay(day);
701-
context.getModel().addAttribute(appts);
702-
context.selectView("appointments");
703-
if (context.isAjaxRequest()) {
704-
//could activate a ViewHelper for component associated with main
705-
context.renderFragment("main");
706-
}
699+
public Map&lt;String, Appointment&gt; getForDay(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date day, Model model) {
700+
return appointmentBook.getAppointmentsForDay(day);
707701
}
708702

709703
<emphasis role="bold">@RequestMapping(value="/new", method = RequestMethod.GET)</emphasis>
@@ -712,8 +706,11 @@ public class AppointmentsController {
712706
}
713707

714708
<emphasis role="bold">@RequestMapping(method = RequestMethod.POST)</emphasis>
715-
public String post(AppointmentForm form) {
716-
appointmentBook.createAppointment(form);
709+
public String add(@Valid AppointmentForm appointment, BindingResult result) {
710+
if (result.hasErrors()) {
711+
return "appointments/new";
712+
}
713+
appointmentBook.addAppointment(appointment);
717714
return "redirect:/appointments";
718715
}
719716
}</programlisting>

0 commit comments

Comments
 (0)