Skip to content

Commit add41f7

Browse files
committed
fix: add the missing form to the model
1 parent 41779af commit add41f7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/de/rwth/idsg/steve/web/controller/ChargePointsController.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ChargePointsController {
3838

3939
@RequestMapping(method = RequestMethod.GET)
4040
public String getAbout(Model model) {
41-
model.addAttribute("cpList", chargePointRepository.getChargeBoxIds());
41+
addList(model);
4242
model.addAttribute("chargeBoxAddForm", new ChargeBoxForm());
4343
model.addAttribute("chargeBoxUpdateForm", new ChargeBoxForm());
4444
return "data-man/chargepoints";
@@ -48,7 +48,8 @@ public String getAbout(Model model) {
4848
public String add(@Valid @ModelAttribute("chargeBoxAddForm") ChargeBoxForm chargeBoxForm,
4949
BindingResult result, Model model) {
5050
if (result.hasErrors()) {
51-
model.addAttribute("cpList", chargePointRepository.getChargeBoxIds());
51+
addList(model);
52+
model.addAttribute("chargeBoxUpdateForm", new ChargeBoxForm());
5253
return "data-man/chargepoints";
5354
}
5455

@@ -60,7 +61,8 @@ public String add(@Valid @ModelAttribute("chargeBoxAddForm") ChargeBoxForm charg
6061
public String update(@Valid @ModelAttribute("chargeBoxUpdateForm") ChargeBoxForm chargeBoxForm,
6162
BindingResult result, Model model) {
6263
if (result.hasErrors()) {
63-
model.addAttribute("cpList", chargePointRepository.getChargeBoxIds());
64+
addList(model);
65+
model.addAttribute("chargeBoxAddForm", new ChargeBoxForm());
6466
return "data-man/chargepoints";
6567
}
6668

@@ -73,4 +75,8 @@ public String delete(@RequestParam String chargeBoxId) {
7375
chargePointRepository.deleteChargePoint(chargeBoxId);
7476
return "redirect:/manager/chargepoints";
7577
}
78+
79+
private void addList(Model model) {
80+
model.addAttribute("cpList", chargePointRepository.getChargeBoxIds());
81+
}
7682
}

0 commit comments

Comments
 (0)