Skip to content

Commit

Permalink
added a demo to show trees and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh0000 committed Jul 28, 2015
1 parent e392669 commit f2b6166
Show file tree
Hide file tree
Showing 15 changed files with 1,063 additions and 0 deletions.
8 changes: 8 additions & 0 deletions TreeAndTable/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/target/
rebel.xml
.metadata
.settings
dist
.faces-config.xml.jsfdia
.project
.classpath
9 changes: 9 additions & 0 deletions TreeAndTable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# BootsFaces-Examples: PrimeFaces, Trees and Tables
This demo is a sketch how to use a tree to filter the content of a data table2

Run this as a Tomcat application. The URL to start typically is http://localhost:8080/BootsFacesTreeAndTable/index.jsf

Tested on:
<ul>
<li>Tomcat 8.0 / Oracle Mojarra 2.2.10</li>
</ul>
103 changes: 103 additions & 0 deletions TreeAndTable/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.beyondjava</groupId>
<artifactId>BootsFacesTreeAndTable</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>BootsFacesTreeAndTable</name>
<url>http://www.beyondjava.net</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.bootsfaces</groupId>
<artifactId>bootsfaces</artifactId>
<version>0.8.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>bootstrap</artifactId>
<version>1.0.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>de.beyondjava</groupId>
<artifactId>angularFaces-core</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>ApplicationServer</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>Mojarra</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.12</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>MyFaces</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.2.7</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.beyondjava.bootsfaces.examples;

import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ViewScoped
@ManagedBean
public class Person {

private String firstName;
private String lastName;
private Date birthdate;
public Date getBirthdate() {
return birthdate;
}
public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package de.beyondjava.jsf.sample.carshop;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

@ManagedBean(name = "treeBasicView")
@ViewScoped
public class BasicView implements Serializable {

private TreeNode root;

@ManagedProperty("#{dynamicOptionBean}")
private DynamicOptionBean dynamicOptions;

@ManagedProperty("#{staticOptionBean}")
private StaticOptionBean staticOptions;

public StaticOptionBean getStaticOptions() {
return staticOptions;
}

public void setStaticOptions(StaticOptionBean staticOptions) {
this.staticOptions = staticOptions;
}

public DynamicOptionBean getDynamicOptions() {
return dynamicOptions;
}

public void setDynamicOptions(DynamicOptionBean dynamicOptions) {
this.dynamicOptions = dynamicOptions;
}

@PostConstruct
public void init() {
root = new DefaultTreeNode("Root", null);
TreeNode all = new DefaultTreeNode("Car pool", root);
List<String> brands = staticOptions.getBrands();
for (String brand : brands) {
if (brand != null && brand.length() > 0) {
TreeNode b = new DefaultTreeNode(brand, all);
List<String> types = dynamicOptions.getTypesToBrand(brand);
for (String type : types) {
if (type != null && type.length() > 0) {
TreeNode t = new DefaultTreeNode(type, b);
}
}
}
}
}

public TreeNode getRoot() {
return root;
}
}
111 changes: 111 additions & 0 deletions TreeAndTable/src/main/java/de/beyondjava/jsf/sample/carshop/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* (C) 2013-2014 Stephan Rauh http://www.beyondjava.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.beyondjava.jsf.sample.carshop;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

public class Car {
String brand;

public int getMileage() {
return mileage;
}

public void setMileage(int mileage) {
this.mileage = mileage;
}

public String getFuel() {
return fuel;
}

public void setFuel(String fuel) {
this.fuel = fuel;
}

public int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

String type;

@Min(1886)
@Max(2014)
int year;

@Min(0)
@Max(1000000)
int mileage;

String fuel;

@Min(1)
@Max(5000000)
int price;

private boolean visible=true;

public Car() {
}

public Car(String brand, String type, int year, String color, int mileage, String fuel, int price) {
this.brand = brand;
this.type = type;
this.year = year;
this.mileage = mileage;
this.fuel = fuel;
this.price = price;
}

public String getBrand() {
return brand;
}


public String getType() {
return type;
}

public int getYear() {
return year;
}

public void setBrand(String brand) {
this.brand = brand;
}

public void setType(String type) {
this.type = type;
}

public void setYear(int year) {
this.year = year;
}

public boolean isVisible() {
return visible;
}

public void setVisible(boolean visible) {
this.visible = visible;
}
}
Loading

0 comments on commit f2b6166

Please sign in to comment.