diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java index 48b33ac41..4fe3bb80d 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java @@ -15,15 +15,10 @@ */ package org.springframework.samples.petclinic.web; -import java.util.Collection; - -import javax.validation.Valid; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.samples.petclinic.model.Owner; import org.springframework.samples.petclinic.service.ClinicService; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; 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.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; 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 @RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.POST) 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.setLastName(ownerRequest.getLastName()); ownerModel.setCity(ownerRequest.getCity());