mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
added comments
This commit is contained in:
parent
41ec22b4be
commit
8fba986a57
1 changed files with 2 additions and 6 deletions
|
@ -15,15 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.web;
|
package org.springframework.samples.petclinic.web;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.samples.petclinic.model.Owner;
|
import org.springframework.samples.petclinic.model.Owner;
|
||||||
import org.springframework.samples.petclinic.service.ClinicService;
|
import org.springframework.samples.petclinic.service.ClinicService;
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
@ -31,7 +26,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +58,8 @@ public class OwnerResource {
|
||||||
// TODO: should be improved so we have a single method parameter
|
// TODO: should be improved so we have a single method parameter
|
||||||
@RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.POST)
|
@RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.POST)
|
||||||
public Owner updateOwner(@ModelAttribute Owner ownerModel, @RequestBody Owner ownerRequest) {
|
public Owner updateOwner(@ModelAttribute Owner ownerModel, @RequestBody Owner ownerRequest) {
|
||||||
|
// seems like a workaround. I haven't found a proper way to inject to have @ModelAttribute pupulate object
|
||||||
|
// first and then have the delta come from @RequestBody
|
||||||
ownerModel.setFirstName(ownerRequest.getFirstName());
|
ownerModel.setFirstName(ownerRequest.getFirstName());
|
||||||
ownerModel.setLastName(ownerRequest.getLastName());
|
ownerModel.setLastName(ownerRequest.getLastName());
|
||||||
ownerModel.setCity(ownerRequest.getCity());
|
ownerModel.setCity(ownerRequest.getCity());
|
||||||
|
|
Loading…
Reference in a new issue