mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:15:50 +00:00
Fix formatting
This commit is contained in:
parent
2fe96130c0
commit
836d111e99
3 changed files with 8 additions and 5 deletions
|
@ -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;
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue