Skip to content

Instantly share code, notes, and snippets.

View koenighotze's full-sized avatar
🎯
Focusing

David Schmitz koenighotze

🎯
Focusing
View GitHub Profile
@koenighotze
koenighotze / pom.xml
Created September 28, 2015 21:35
JEE7 Basic Pom
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.koenighotze</groupId>
<artifactId>jee7helloworld</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jee7helloworld Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
@koenighotze
koenighotze / web.xml
Created September 28, 2015 21:36
JEE7 Basic Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
@koenighotze
koenighotze / index.xhtml
Created September 28, 2015 21:39
JEE Demo Helloworld Index
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<body>
<form jsf:id="form">
What is your name: <input type="text" jsf:value="#{hello.name}"/>
<input type="submit" value="Greet me" jsf:action="hello.xhtml"/>
</form>
</body>
@koenighotze
koenighotze / hello.xhtml
Created September 28, 2015 21:39
Hello world
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
Hello #{hello.name}
<br/>
<a href="index.xhtml">Back</a>
</body>
</html>
@koenighotze
koenighotze / Hello.java
Created September 28, 2015 21:40
Hello without ORM
package hello;
import javax.enterprise.inject.Model;
import java.io.Serializable;
@Model
public class Hello implements Serializable {
private String name;
public String getName() {
@koenighotze
koenighotze / HelloController.java
Created September 28, 2015 21:47
Basic Controller
package hello;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaQuery;
import javax.transaction.Transactional;
import java.util.List;
@koenighotze
koenighotze / index.xhtml
Created September 28, 2015 21:49
Hello World with List
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<body>
<form jsf:id="form">
What is your name: <input type="text" jsf:value="#{hello.name}"/>
<input type="submit" value="Greet me" jsf:actionListener="#{helloController.storeName(hello)}" jsf:action="hello.xhtml"/>
</form>
<br/>
@koenighotze
koenighotze / persistence.xml
Created September 28, 2015 21:52
persistence xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="JEE7HelloWorld-Booking" transaction-type="JTA">
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
@koenighotze
koenighotze / HelloController.java
Created September 29, 2015 21:41
JAX-RS REST support in controller
@Named
@ApplicationScoped
@Path("hello")
public class HelloController {
@Inject
private Hello hello;
@PersistenceContext
private EntityManager em;
@koenighotze
koenighotze / Application.java
Created September 29, 2015 21:42
JAX-RS Application
@javax.ws.rs.ApplicationPath("rest")
public class Application extends javax.ws.rs.core.Application {
}