fixed incorrect example and JSF reference
This commit is contained in:
parent
3361de3875
commit
4e35c59a20
|
|
@ -676,7 +676,7 @@ public class HelloWorldController {
|
||||||
for a specific HTTP method request method ("GET"/"POST") or specific
|
for a specific HTTP method request method ("GET"/"POST") or specific
|
||||||
HTTP request parameters.</para>
|
HTTP request parameters.</para>
|
||||||
|
|
||||||
<para>The following example shows a controller in a JSF application
|
<para>The following example shows a controller in a Spring MVC application
|
||||||
that uses this annotation:</para>
|
that uses this annotation:</para>
|
||||||
|
|
||||||
<programlisting language="java">@Controller
|
<programlisting language="java">@Controller
|
||||||
|
|
@ -691,19 +691,13 @@ public class AppointmentsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
<emphasis role="bold">@RequestMapping(method = RequestMethod.GET)</emphasis>
|
<emphasis role="bold">@RequestMapping(method = RequestMethod.GET)</emphasis>
|
||||||
public Appointments get() {
|
public Map<String, Appointment> get() {
|
||||||
return appointmentBook.getAppointmentsForToday();
|
return appointmentBook.getAppointmentsForToday();
|
||||||
}
|
}
|
||||||
|
|
||||||
<emphasis role="bold">@RequestMapping(value="/{day}", method = RequestMethod.GET)</emphasis>
|
<emphasis role="bold">@RequestMapping(value="/{day}", method = RequestMethod.GET)</emphasis>
|
||||||
public void getForDay(@PathVariable Date day, ExternalContext context) {
|
public Map<String, Appointment> getForDay(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date day, Model model) {
|
||||||
Appointments appts = appointmentBook.getAppointmentsForDay(day);
|
return 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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<emphasis role="bold">@RequestMapping(value="/new", method = RequestMethod.GET)</emphasis>
|
<emphasis role="bold">@RequestMapping(value="/new", method = RequestMethod.GET)</emphasis>
|
||||||
|
|
@ -712,8 +706,11 @@ public class AppointmentsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
<emphasis role="bold">@RequestMapping(method = RequestMethod.POST)</emphasis>
|
<emphasis role="bold">@RequestMapping(method = RequestMethod.POST)</emphasis>
|
||||||
public String post(AppointmentForm form) {
|
public String add(@Valid AppointmentForm appointment, BindingResult result) {
|
||||||
appointmentBook.createAppointment(form);
|
if (result.hasErrors()) {
|
||||||
|
return "appointments/new";
|
||||||
|
}
|
||||||
|
appointmentBook.addAppointment(appointment);
|
||||||
return "redirect:/appointments";
|
return "redirect:/appointments";
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue