commit 222904056d3b003678f771d1de33b147af9144f6 Author: Tim Holloway Date: Tue Dec 28 06:40:09 2021 -0500 Initial commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..449efaf --- /dev/null +++ b/.classpath @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..e2034e0 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + jsf-primefaces-datatable + JSF PrimeFaces DataTable Example. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cb34bbb --- /dev/null +++ b/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + com.codenotfound + jsf-primefaces-datatable + 0.0.1-SNAPSHOT + jar + + jsf-primefaces-datatable + JSF PrimeFaces DataTable Example + https://codenotfound.com/jsf-primefaces-datatable-example.html + + + org.springframework.boot + spring-boot-starter-parent + 2.1.0.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 3.3.0-rc2 + + + + + + org.joinfaces + joinfaces-dependencies + ${joinfaces.version} + pom + import + + + + + + + org.joinfaces + primefaces-spring-boot-starter + + + javax.enterprise + cdi-api + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java b/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java new file mode 100644 index 0000000..8bca1aa --- /dev/null +++ b/src/main/java/com/codenotfound/SpringPrimeFacesApplication.java @@ -0,0 +1,12 @@ +package com.codenotfound; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringPrimeFacesApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringPrimeFacesApplication.class, args); + } +} diff --git a/src/main/java/com/codenotfound/primefaces/Car.java b/src/main/java/com/codenotfound/primefaces/Car.java new file mode 100644 index 0000000..4ccd6d9 --- /dev/null +++ b/src/main/java/com/codenotfound/primefaces/Car.java @@ -0,0 +1,64 @@ +package com.codenotfound.primefaces; + +import java.io.Serializable; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity(name = "Car") +public class Car implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String brand; + + private int year; + + private String color; + + public Car() {} + + public Car(Long id, String brand, int year, String color) { + this.id = id; + this.brand = brand; + this.year = year; + this.color = color; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } +} diff --git a/src/main/java/com/codenotfound/primefaces/CarRepository.java b/src/main/java/com/codenotfound/primefaces/CarRepository.java new file mode 100644 index 0000000..65ad0ba --- /dev/null +++ b/src/main/java/com/codenotfound/primefaces/CarRepository.java @@ -0,0 +1,8 @@ +package com.codenotfound.primefaces; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CarRepository extends JpaRepository { +} diff --git a/src/main/java/com/codenotfound/primefaces/CarsView.java b/src/main/java/com/codenotfound/primefaces/CarsView.java new file mode 100644 index 0000000..bdbc96b --- /dev/null +++ b/src/main/java/com/codenotfound/primefaces/CarsView.java @@ -0,0 +1,29 @@ +package com.codenotfound.primefaces; + +import java.io.Serializable; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; + +@Named +@ViewScoped +public class CarsView implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + private CarRepository carRepository; + + private List cars; + + @PostConstruct + public void init() { + cars = carRepository.findAll(); + } + + public List getCars() { + return cars; + } +} diff --git a/src/main/resources/META-INF/resources/cars.xhtml b/src/main/resources/META-INF/resources/cars.xhtml new file mode 100644 index 0000000..8b63dfd --- /dev/null +++ b/src/main/resources/META-INF/resources/cars.xhtml @@ -0,0 +1,32 @@ + + + + + + PrimeFaces DataTable Example + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..cb6b1aa --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1,11 @@ +INSERT INTO car (brand, year, color) VALUES + ('Audi', 1992, 'Red'), + ('Fiat', 2001, 'Red'), + ('Mercedes', 1991, 'Brown'), + ('Fiat', 1962, 'Black'), + ('Renault', 1997, 'Brown'), + ('Renault', 1967, 'Maroon'), + ('Renault', 1986, 'Yellow'), + ('BMW', 1970, 'Maroon'), + ('Fiat', 1990, 'Silver'), + ('Renault', 1972, 'Black');