Skip to content

Commit 4e86525

Browse files
committed
country/info.html: put to context separate variables instead of single object.
Make view not aware of structure and type of the object (entity/dto/etc) and also allow to easy determine where and what methods of the object were used. Related to #120
1 parent ae3ca6d commit 4e86525

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public String showInfo(
100100
return null;
101101
}
102102

103-
model.addAttribute("country", country);
103+
model.addAttribute("countryId", country.getId());
104+
model.addAttribute("countrySlug", country.getSlug());
105+
model.addAttribute("countryName", LocaleUtils.getLocalizedName(userLocale, country));
104106

105107
String lang = LocaleUtils.getLanguageOrNull(userLocale);
106108
Integer countryId = country.getId();

src/main/webapp/WEB-INF/views/country/info.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" th:href="${BOOTSTRAP_CSS}" />
1313
<link rel="stylesheet" href="https://cdn.rawgit.com/usrz/bootstrap-languages/3ac2a3d2b27ac43a471cd99e79d378a03b2c6b5f/languages.min.css" th:href="${BOOTSTRAP_LANGUAGE}" />
1414
<link rel="stylesheet" href="../../static/styles/main.css" th:href="${MAIN_CSS}" />
15-
<link rel="canonical" href="" th:href="@{${PUBLIC_URL} + ${INFO_COUNTRY_PAGE}(id=${country.id},slug=${country.slug})}" />
15+
<link rel="canonical" href="" th:href="@{${PUBLIC_URL} + ${INFO_COUNTRY_PAGE}(id=${countryId},slug=${countrySlug})}" />
1616
</head>
1717
<body>
1818
<div class="container-fluid">
@@ -87,13 +87,13 @@
8787
</div>
8888
<div class="row">
8989
<div id="content" class="col-sm-12">
90-
<h3 th:text="${country.getLocalizedName(#locale)}">
90+
<h3 th:text="${countryName}">
9191
Italy
9292
</h3>
9393

9494
<!--/*/
9595
<div class="row" th:if="${justAddedCountry}">
96-
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_country_just_added(@{${ADD_SERIES_WITH_COUNTRY_PAGE}(id=${country.id})})}">
96+
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_country_just_added(@{${ADD_SERIES_WITH_COUNTRY_PAGE}(id=${countryId})})}">
9797
Country has been added.<br />
9898
Now you could <a href="../series/add.html" class="alert-link">proceed with creating series</a>.
9999
</div>

0 commit comments

Comments
 (0)