■2022/12/29 更新:
掲載ソースのTodolist15一部差替■2022/12/30 補足:
「21.3 表示データの限定」
:
public class TodoData {
private Integer id;
private Integer ownerId; // !!!この行を追加!!!
@NotBlank
private String title;
:
public Todo toEntity() {
Todo todo = new Todo();
// ToDo
todo.setId(id);
todo.setOwnerId(ownerId); // !!!この行を追加!!!
todo.setTitle(title);
:
return todo;
}
public TodoData(Todo todo, List attachedFiles) {
// Todo部分
this.id = todo.getId();
this.ownerId = todo.getOwnerId(); // !!!この行を追加!!!
this.title = todo.getTitle();
:
}
:
}
:
■ToDo
<!-- ToDO入力エリア -->
<table>
<!-- id -->
<tr>
<th>id</th>
<td>
<span th:text="*{id}"></span>
<!-- 更新 のために必要 -->
<input type="hidden" th:field="*{id}">
<input type="hidden" th:field="*{ownerId}"><!-- !!!この行を追加!!! -->
</td>
:
#最後に以下の1行を追加 msg.e.operation_error=Not the operator's todo
#最後に以下の1行を追加 msg.e.operation_error=操作者のTodoではありません。
■2022/12/30 訂正:
「13.2 フラグメント(th:fragment/th:insert)」
フラグメントにする部分は~{ビュー名::th:fragmentで付けた名前}のように~{}で囲んでください。
~{}で囲まない記法はdeprecated(非推奨)になり、将来廃止される可能性があります。
Thymeleaf 3.1: What’s new and how to migrate
> 2.6 Deprecation of unwrapped fragment expressions 参照
よってリスト13-9, 13-10はそれぞれ以下のようにしてください。
【リスト13-9】src/main/resources/templates/todoList.html(変更箇所)
<!DOCTYPE html>
:
<body>
<!-- 操作メッセージエリア -->
<div th:replace="~{fragments :: msg_area}"></div>
<!-- 検索条件入力エリア -->
<form th:action="@{/}" method="post" th:object="${todoQuery}">
:
<!DOCTYPE html>
:
<body>
<!-- 操作メッセージエリア -->
<div th:replace="~{fragments :: msg_area}"></div>
<!-- 入力フォーム -->
<form th:action="@{/}" method="post" th:object="${todoData}">
:
問い合わせ先:kktworks@gmail.com
Twitter:Follow @kktworks1