From 59d944fccd38514d21709b072eac6eefb27c030b Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Fri, 17 May 2019 20:56:01 +0200 Subject: [PATCH] fully working version Signed-off-by: Johannes Theiner --- src/main/java/de/hsel/itech/jsf/BookBean.java | 21 +++++++------ src/main/webapp/bookinfo.xhtml | 31 +++++++++++++------ src/main/webapp/category.xhtml | 3 +- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/hsel/itech/jsf/BookBean.java b/src/main/java/de/hsel/itech/jsf/BookBean.java index 8a574bb..e135261 100644 --- a/src/main/java/de/hsel/itech/jsf/BookBean.java +++ b/src/main/java/de/hsel/itech/jsf/BookBean.java @@ -7,12 +7,12 @@ import lombok.Setter; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; -import javax.faces.bean.ViewScoped; +import javax.faces.bean.RequestScoped; import java.util.ArrayList; import java.util.List; @ManagedBean -@ViewScoped +@RequestScoped public class BookBean { @Getter @@ -21,26 +21,29 @@ public class BookBean { private Book book; public String select() { - - return "/bookinfo.jsf"; + return "/bookinfo.xhtml"; } - public String getPrice(){ + public String back() { + return "/category.xhtml"; + } + + public String getPrice() { String res = ""; res += book.getPrice() / 100; - res+= ","; - if(book.getPrice() % 100 < 10){ + res += ","; + if (book.getPrice() % 100 < 10) { res += "0"; } res += book.getPrice() % 100; return res; } - public String getAuthors(){ + public String getAuthors() { List authors = new ArrayList<>(); for (Author author : book.getAuthors()) { authors.add(author.getName()); } - return String.join(", ",authors); + return String.join(", ", authors); } } diff --git a/src/main/webapp/bookinfo.xhtml b/src/main/webapp/bookinfo.xhtml index 66a7e18..c05ee7b 100644 --- a/src/main/webapp/bookinfo.xhtml +++ b/src/main/webapp/bookinfo.xhtml @@ -11,25 +11,39 @@ -
+ + + + + + + + + + +
- Buchcover +
-

#{bookInfo.book.title}

+

#{bookBean.book.title}


- #{bookInfo.authors} -

+ #{bookBean.authors} +
- #{bookInfo.book.description} + #{bookBean.book.description}
-

#{bookInfo.price} €

+

#{bookBean.price} €


gewöhnlich versandfertig in 2-3 Tagen
@@ -42,8 +56,7 @@
- - +
diff --git a/src/main/webapp/category.xhtml b/src/main/webapp/category.xhtml index b220064..bf0ba72 100644 --- a/src/main/webapp/category.xhtml +++ b/src/main/webapp/category.xhtml @@ -11,8 +11,7 @@ - +

Kategorien