Skip to content

Commit ae3ca6d

Browse files
committed
category/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 71ec4fc commit ae3ca6d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

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

103-
model.addAttribute("category", category);
103+
model.addAttribute("categoryId", category.getId());
104+
model.addAttribute("categorySlug", category.getSlug());
105+
model.addAttribute("categoryName", LocaleUtils.getLocalizedName(userLocale, category));
104106

105107
String lang = LocaleUtils.getLanguageOrNull(userLocale);
106108
Integer categoryId = category.getId();

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

+3-3
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_CATEGORY_PAGE}(id=${category.id},slug=${category.slug})}" />
15+
<link rel="canonical" href="" th:href="@{${PUBLIC_URL} + ${INFO_CATEGORY_PAGE}(id=${categoryId},slug=${categorySlug})}" />
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="${category.getLocalizedName(#locale)}">
90+
<h3 th:text="${categoryName}">
9191
Animals
9292
</h3>
9393

9494
<!--/*/
9595
<div class="row" th:if="${justAddedCategory}">
96-
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_category_just_added(@{${ADD_SERIES_WITH_CATEGORY_PAGE}(id=${category.id})})}">
96+
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_category_just_added(@{${ADD_SERIES_WITH_CATEGORY_PAGE}(id=${categoryId})})}">
9797
Category 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)