Skip to content

Commit e0e22c5

Browse files
committed
SeriesController: remove usage of @ModelAttribute.
Follow-up to 56d7d24 commit. No functional changes.
1 parent 56d7d24 commit e0e22c5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/main/java/ru/mystamps/web/controller/SeriesController.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,8 @@ protected void initBinder(WebDataBinder binder) {
118118
binder.registerCustomEditor(String.class, "comment", new StringTrimmerEditor(true));
119119
}
120120

121-
@ModelAttribute("years")
122-
public Map<Integer, Integer> getYears() {
123-
return YEARS;
124-
}
125-
126-
@ModelAttribute("countries")
127-
public List<LinkEntityDto> getCountries(Locale userLocale) {
128-
String lang = LocaleUtils.getLanguageOrNull(userLocale);
129-
return countryService.findAllAsLinkEntities(lang);
130-
}
131-
132121
@GetMapping(Url.ADD_SERIES_PAGE)
133-
public AddSeriesForm showForm(
122+
public void showForm(
134123
@Category @RequestParam(name = "category", required = false) LinkEntityDto category,
135124
@Country @RequestParam(name = "country", required = false) LinkEntityDto country,
136125
Model model,
@@ -141,6 +130,11 @@ public AddSeriesForm showForm(
141130
List<FirstLevelCategoryDto> categories = categoryService.findFirstLevelCategories(lang);
142131
model.addAttribute("categories", categories);
143132

133+
List<LinkEntityDto> countries = countryService.findAllAsLinkEntities(lang);
134+
model.addAttribute("countries", countries);
135+
136+
model.addAttribute("years", YEARS);
137+
144138
AddSeriesForm addSeriesForm = new AddSeriesForm();
145139
addSeriesForm.setPerforated(true);
146140

@@ -152,7 +146,7 @@ public AddSeriesForm showForm(
152146
addSeriesForm.setCountry(country);
153147
}
154148

155-
return addSeriesForm;
149+
model.addAttribute("addSeriesForm", addSeriesForm);
156150
}
157151

158152
@GetMapping(Url.ADD_SERIES_WITH_CATEGORY_PAGE)
@@ -199,6 +193,11 @@ public String processInput(
199193
List<FirstLevelCategoryDto> categories = categoryService.findFirstLevelCategories(lang);
200194
model.addAttribute("categories", categories);
201195

196+
List<LinkEntityDto> countries = countryService.findAllAsLinkEntities(lang);
197+
model.addAttribute("countries", countries);
198+
199+
model.addAttribute("years", YEARS);
200+
202201
// don't try to re-display file upload field
203202
form.setImage(null);
204203
return null;

0 commit comments

Comments
 (0)