Browse Source

Get current year for new books

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.1-alpha
Pekka Helenius 4 years ago
parent
commit
71d5c71fdf
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java

+ 9
- 1
bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java View File

@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import java.time.Year;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.fjordtek.bookstore.model.*; import com.fjordtek.bookstore.model.*;
@ -63,7 +65,13 @@ public class BookController {
bookAddPageURL + ": " + "HTTPOK" bookAddPageURL + ": " + "HTTPOK"
); );
dataModel.addAttribute("book", new Book());
Book newBook = new Book();
dataModel.addAttribute("book", newBook);
if (newBook.getYear() == 0) {
newBook.setYear(Year.now().getValue());
}
return bookAddPageURL; return bookAddPageURL;
} }


Loading…
Cancel
Save