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 / index.xhtml
Created September 29, 2015 21:43
JSF View with table
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:ui="http://java.sun.com/jsf/facelets">
<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 / Hello.java
Created September 29, 2015 21:42
Entity/REST Support
@Model
@Entity
@XmlRootElement
public class Hello implements Serializable {
@Id
private String name;
public String getName() {
return name;
}
@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 {
}
@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 / 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 / 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 / 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 / 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 / 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 / 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>