From 588fd808f860ff0896eb2e4cb841f8cacd19855b Mon Sep 17 00:00:00 2001 From: Soumen Mallick Date: Sat, 21 Dec 2024 01:17:21 +0530 Subject: [PATCH] Pet update fix --- .../samples/petclinic/owner/PetController.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java index fcf431bff68..866c55a0f2c 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java @@ -17,6 +17,7 @@ import java.time.LocalDate; import java.util.Collection; +import java.util.List; import java.util.Optional; import org.springframework.stereotype.Controller; @@ -42,7 +43,7 @@ */ @Controller @RequestMapping("/owners/{ownerId}") -class PetController { +class privatePetController { private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm"; @@ -146,7 +147,18 @@ public String processUpdateForm(Owner owner, @Valid Pet pet, BindingResult resul return VIEWS_PETS_CREATE_OR_UPDATE_FORM; } - owner.addPet(pet); + //owner.addPet(pet); + + List petlist = owner.getPets(); + for(int i=0 ; i