fully working version

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2019-05-17 20:56:01 +02:00
parent 960f58c8c1
commit 59d944fccd
3 changed files with 35 additions and 20 deletions

View File

@ -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<String> authors = new ArrayList<>();
for (Author author : book.getAuthors()) {
authors.add(author.getName());
}
return String.join(", ",authors);
return String.join(", ", authors);
}
}

View File

@ -11,25 +11,39 @@
<ui:define name="content">
<div class="m-row">
<h:form>
<h:commandLink action="#{bookBean.back}" value="zurück zur Auswahl" rendered="#{not empty bookBean}"/>
</h:form>
<h:panelGroup layout="block" rendered="#{empty bookBean.book}">
<aside class="m-note m-danger">
<h1 class="m-text-center">Dieses Buch exsistiert leider nicht</h1>
</aside>
<h:graphicImage value="https://source.unsplash.com/tEMU4lzAL0w/900x900"/>
</h:panelGroup>
<h:panelGroup layout="block" styleClass="m-row" rendered="#{not empty bookBean.book}">
<div class="m-col-l-4">
<img class="m-image" src="https://source.unsplash.com/#{bookInfo.book.image}/900x900" alt="Buchcover"/>
<h:graphicImage styleClass="m-image"
value="https://source.unsplash.com/#{bookBean.book.image}/900x900"
alt="Buchcover"/>
</div>
<div class="m-col-l-4">
<h1>#{bookInfo.book.title}</h1>
<h1>#{bookBean.book.title}</h1>
<br/>
<h2>
#{bookInfo.authors}
</h2>
#{bookBean.authors}
</h2>
<br/>
<span>
#{bookInfo.book.description}
#{bookBean.book.description}
</span>
</div>
<div class="m-col-l-4">
<div class="m-block">
<h3>#{bookInfo.price} &#8364;</h3>
<h3>#{bookBean.price} &#8364;</h3>
<br/>
gewöhnlich versandfertig in <span class="m-text m-success">2-3 Tagen</span>
<br/>
@ -42,8 +56,7 @@
</div>
</div>
</div>
</div>
</h:panelGroup>
</ui:define>

View File

@ -11,8 +11,7 @@
<ui:define name="content">
<h:form>
<h:commandLink action="#{categoryBean.back}" value="zurück zur Auswahl"
rendered="#{not empty categoryBean.category}"/>
<h:commandLink action="#{categoryBean.back}" value="zurück zur Auswahl" rendered="#{not empty categoryBean.category}"/>
<h:panelGroup layout="block" styleClass="m-row" rendered="#{empty categoryBean.category}">
<h1 class="m-text-center">Kategorien</h1>