summaryrefslogtreecommitdiff
path: root/spring-boot/10-role-based-security/src/main/resources/templates/security
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-06-20 22:02:32 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-06-20 22:02:32 +0530
commit69b18c1fe1d7d876c86de850b716de396877ad9d (patch)
tree832330933dccb4848ba0ff89a9f4f5953b3da3e7 /spring-boot/10-role-based-security/src/main/resources/templates/security
parent59c2d3502259b338c36991ced8dc25d8dc9713b1 (diff)
A list of users are shown. Added error pages.
Diffstat (limited to 'spring-boot/10-role-based-security/src/main/resources/templates/security')
-rw-r--r--spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html22
-rw-r--r--spring-boot/10-role-based-security/src/main/resources/templates/security/users.html30
2 files changed, 52 insertions, 0 deletions
diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html b/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html
new file mode 100644
index 0000000..a27ae7d
--- /dev/null
+++ b/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org"
+ th:replace="~{layout/main :: layout(title='User', content=~{::main})}">
+
+<body>
+ <main>
+ <form th:action="@{/security/user/update}" th:object="${userForm}" method="post">
+ <!-- Hidden field binds the "id" property seamlessly -->
+ <input type="hidden" th:field="*{id}" />
+
+ <div class="form-field-container">
+ <label>Description</label>
+ <textarea th:field="*{description}" placeholder="Description"></textarea>
+ <div class="validation-error" th:if="${#fields.hasErrors('description')}" th:errors="*{description}"></div>
+ </div>
+
+ <button type="submit">Save</button>
+ </form>
+ </main>
+</body>
+
+</html> \ No newline at end of file
diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html b/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html
new file mode 100644
index 0000000..81752c8
--- /dev/null
+++ b/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org"
+ th:replace="~{layout/main :: layout(title='Users', content=~{::main})}">
+
+<body>
+ <main>
+ <table>
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Username</th>
+ <th>Description</th>
+ <th>Edit</th>
+ </tr>
+ </thead>
+ <tbody>
+ <!-- th:each loops over the "userss" list sent by the controller -->
+ <tr th:each="user : ${users}">
+ <!-- th:text updates the cell contents dynamically -->
+ <td th:text="${user.id}">1</td>
+ <td th:text="${user.username}">Username</td>
+ <td th:text="${user.description}">User description</td>
+ <td><a th:href="@{/security/user/update/{id}(id=${user.id})}">Edit</a></td>
+ </tr>
+ </tbody>
+ </table>
+ </main>
+</body>
+
+</html> \ No newline at end of file