From 588fd808f860ff0896eb2e4cb841f8cacd19855b Mon Sep 17 00:00:00 2001 From: Soumen Mallick Date: Sat, 21 Dec 2024 01:17:21 +0530 Subject: [PATCH 1/2] 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 Date: Sun, 22 Dec 2024 12:34:20 +0530 Subject: [PATCH 2/2] updatePet meyhod added in Owner ! --- pom.xml | 8 +++++++- .../samples/petclinic/owner/Owner.java | 13 +++++++++++++ .../samples/petclinic/owner/PetController.java | 10 +++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9b9b815df40..45598cbe801 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ - 17 + 21 UTF-8 UTF-8