Fix formatting

This commit is contained in:
Dave Syer 2024-01-31 21:52:37 +00:00
parent 2fe96130c0
commit 836d111e99
3 changed files with 8 additions and 5 deletions

View file

@ -137,7 +137,7 @@ class OwnerController {
@PostMapping("/owners/{ownerId}/edit") @PostMapping("/owners/{ownerId}/edit")
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId, public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId,
RedirectAttributes redirectAttributes) { RedirectAttributes redirectAttributes) {
if (result.hasErrors()) { if (result.hasErrors()) {
redirectAttributes.addFlashAttribute("error", "There was an error in updating the owner."); redirectAttributes.addFlashAttribute("error", "There was an error in updating the owner.");
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM; return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;

View file

@ -99,7 +99,8 @@ class PetController {
} }
@PostMapping("/pets/new") @PostMapping("/pets/new")
public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model, RedirectAttributes redirectAttributes) { public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model,
RedirectAttributes redirectAttributes) {
if (StringUtils.hasText(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) { if (StringUtils.hasText(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) {
result.rejectValue("name", "duplicate", "already exists"); result.rejectValue("name", "duplicate", "already exists");
} }
@ -121,14 +122,16 @@ class PetController {
} }
@GetMapping("/pets/{petId}/edit") @GetMapping("/pets/{petId}/edit")
public String initUpdateForm(Owner owner, @PathVariable("petId") int petId, ModelMap model,RedirectAttributes redirectAttributes) { public String initUpdateForm(Owner owner, @PathVariable("petId") int petId, ModelMap model,
RedirectAttributes redirectAttributes) {
Pet pet = owner.getPet(petId); Pet pet = owner.getPet(petId);
model.put("pet", pet); model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM; return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
} }
@PostMapping("/pets/{petId}/edit") @PostMapping("/pets/{petId}/edit")
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model,RedirectAttributes redirectAttributes) { public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model,
RedirectAttributes redirectAttributes) {
String petName = pet.getName(); String petName = pet.getName();

View file

@ -82,7 +82,7 @@ class VisitController {
// called // called
@PostMapping("/owners/{ownerId}/pets/{petId}/visits/new") @PostMapping("/owners/{ownerId}/pets/{petId}/visits/new")
public String processNewVisitForm(@ModelAttribute Owner owner, @PathVariable int petId, @Valid Visit visit, public String processNewVisitForm(@ModelAttribute Owner owner, @PathVariable int petId, @Valid Visit visit,
BindingResult result, RedirectAttributes redirectAttributes) { BindingResult result, RedirectAttributes redirectAttributes) {
if (result.hasErrors()) { if (result.hasErrors()) {
return "pets/createOrUpdateVisitForm"; return "pets/createOrUpdateVisitForm";
} }