fully working version
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
960f58c8c1
commit
59d944fccd
|
@ -7,12 +7,12 @@ import lombok.Setter;
|
||||||
|
|
||||||
import javax.faces.bean.ManagedBean;
|
import javax.faces.bean.ManagedBean;
|
||||||
import javax.faces.bean.ManagedProperty;
|
import javax.faces.bean.ManagedProperty;
|
||||||
import javax.faces.bean.ViewScoped;
|
import javax.faces.bean.RequestScoped;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ManagedBean
|
@ManagedBean
|
||||||
@ViewScoped
|
@RequestScoped
|
||||||
public class BookBean {
|
public class BookBean {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -21,26 +21,29 @@ public class BookBean {
|
||||||
private Book book;
|
private Book book;
|
||||||
|
|
||||||
public String select() {
|
public String select() {
|
||||||
|
return "/bookinfo.xhtml";
|
||||||
return "/bookinfo.jsf";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrice(){
|
public String back() {
|
||||||
|
return "/category.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrice() {
|
||||||
String res = "";
|
String res = "";
|
||||||
res += book.getPrice() / 100;
|
res += book.getPrice() / 100;
|
||||||
res+= ",";
|
res += ",";
|
||||||
if(book.getPrice() % 100 < 10){
|
if (book.getPrice() % 100 < 10) {
|
||||||
res += "0";
|
res += "0";
|
||||||
}
|
}
|
||||||
res += book.getPrice() % 100;
|
res += book.getPrice() % 100;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthors(){
|
public String getAuthors() {
|
||||||
List<String> authors = new ArrayList<>();
|
List<String> authors = new ArrayList<>();
|
||||||
for (Author author : book.getAuthors()) {
|
for (Author author : book.getAuthors()) {
|
||||||
authors.add(author.getName());
|
authors.add(author.getName());
|
||||||
}
|
}
|
||||||
return String.join(", ",authors);
|
return String.join(", ", authors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,25 +11,39 @@
|
||||||
|
|
||||||
<ui:define name="content">
|
<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">
|
<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>
|
||||||
<div class="m-col-l-4">
|
<div class="m-col-l-4">
|
||||||
<h1>#{bookInfo.book.title}</h1>
|
<h1>#{bookBean.book.title}</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<h2>
|
<h2>
|
||||||
#{bookInfo.authors}
|
#{bookBean.authors}
|
||||||
</h2>
|
</h2>
|
||||||
<br/>
|
<br/>
|
||||||
<span>
|
<span>
|
||||||
#{bookInfo.book.description}
|
#{bookBean.book.description}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="m-col-l-4">
|
<div class="m-col-l-4">
|
||||||
<div class="m-block">
|
<div class="m-block">
|
||||||
<h3>#{bookInfo.price} €</h3>
|
<h3>#{bookBean.price} €</h3>
|
||||||
<br/>
|
<br/>
|
||||||
gewöhnlich versandfertig in <span class="m-text m-success">2-3 Tagen</span>
|
gewöhnlich versandfertig in <span class="m-text m-success">2-3 Tagen</span>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -42,8 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</h:panelGroup>
|
||||||
|
|
||||||
|
|
||||||
</ui:define>
|
</ui:define>
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form>
|
<h:form>
|
||||||
<h:commandLink action="#{categoryBean.back}" value="zurück zur Auswahl"
|
<h:commandLink action="#{categoryBean.back}" value="zurück zur Auswahl" rendered="#{not empty categoryBean.category}"/>
|
||||||
rendered="#{not empty categoryBean.category}"/>
|
|
||||||
|
|
||||||
<h:panelGroup layout="block" styleClass="m-row" rendered="#{empty categoryBean.category}">
|
<h:panelGroup layout="block" styleClass="m-row" rendered="#{empty categoryBean.category}">
|
||||||
<h1 class="m-text-center">Kategorien</h1>
|
<h1 class="m-text-center">Kategorien</h1>
|
||||||
|
|
Loading…
Reference in New Issue