From 128ee7ef0417d9f69f4dd88fcd5bb920e7059b05 Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Fri, 18 Sep 2020 02:02:26 +0300 Subject: [PATCH] Simplify code of retrieving current year in add form; fix typo Signed-off-by: Pekka Helenius --- .../java/com/fjordtek/bookstore/web/BookController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java index 26cb4c3..82003ad 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java @@ -96,13 +96,10 @@ public class BookController { ) { Book newBook = new Book(); - dataModel.addAttribute("book", new Book()); + newBook.setYear(Year.now().getValue()); + dataModel.addAttribute("book", newBook); dataModel.addAttribute("categories", categoryRepository.findAll()); - if (newBook.getYear() == 0) { - newBook.setYear(Year.now().getValue()); - } - httpServerLogger.logMessageNormal( requestData, bookAddPageView + ": " + "HTTPOK"