+ dropdown with categories, not working fully
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
3f727eae72
commit
32896e0cc3
62
pom.xml
62
pom.xml
@ -45,38 +45,38 @@
|
||||
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<url>https://tomcat.joethei.space/manager/text</url>
|
||||
<server>TomcatServer</server>
|
||||
<path>/itech</path>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<url>https://tomcat.joethei.space/manager/text</url>
|
||||
<server>TomcatServer</server>
|
||||
<path>/itech</path>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,29 +1,34 @@
|
||||
package de.hsel.itech.jsf;
|
||||
|
||||
import de.hsel.itech.db.Database;
|
||||
import de.hsel.itech.db.pojo.Book;
|
||||
import de.hsel.itech.db.pojo.Category;
|
||||
|
||||
import javax.faces.bean.ApplicationScoped;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ViewScoped;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ManagedBean
|
||||
@ApplicationScoped
|
||||
@ViewScoped
|
||||
public class CategoryBean implements Serializable {
|
||||
|
||||
private String hello = "Hallo Welt";
|
||||
private Category category;
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
|
||||
public String getHello() {
|
||||
return hello;
|
||||
}
|
||||
|
||||
public List<Category> getCategories() {
|
||||
return Database.getInstance().getCategories();
|
||||
}
|
||||
|
||||
public String test() {
|
||||
return "";
|
||||
public List<Book> getBooks() {
|
||||
return Database.getInstance().getBooks(category);
|
||||
}
|
||||
|
||||
}
|
@ -6,15 +6,24 @@
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<h:head>
|
||||
<title>Amazon light</title>
|
||||
<title>Amazon light</title>
|
||||
</h:head>
|
||||
|
||||
<h:body>
|
||||
|
||||
<ui:repeat value="#{categoryBean.categories}" var="category">
|
||||
<h:outputText value="#{category.name}"/>
|
||||
<br/>
|
||||
</ui:repeat>
|
||||
|
||||
<h:form>
|
||||
<h:selectOneMenu value="#{categoryBean.category}" onchange="this.form.submit()">
|
||||
<f:selectItems value="#{categoryBean.categories}" var="category" itemValue="#{category.id}" itemLabel="#{category.name}"/>
|
||||
</h:selectOneMenu>
|
||||
</h:form>
|
||||
|
||||
|
||||
<ui:repeat value="#{categoryBean.books}" var="book" rendered="not empty #{categoryBean.category}">
|
||||
<h:outputText value="#{book.title}"/>
|
||||
<h:graphicImage value="https://source.unsplash.com/#{book.image}/150x150"/>
|
||||
<br/>
|
||||
</ui:repeat>
|
||||
</h:body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user