Simple HTML5 Friendly Markup Sample
- by Geertjan
From a demo done by David Heffelfinger (who has a great Java EE 7 screencast series here), on HTML5 friendly markup.
index.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<title>Data Entry Page</title>
<body>
<form method="POST" jsf:id='form'>
<table>
<tr>
<td>Name:</td>
<td><input jsf:id='name' type="text" jsf:value="${person.name}" /></td>
</tr>
<tr>
<td>City</td>
<th><input jsf:id='city' type="text" jsf:value="${person.city}"/></th>
</tr>
<tr>
<td><input type="submit" value="Submit" jsf:action="confirmation" /></td>
</tr>
</table>
</form>
</body>
</html>
confirmation.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Data Confirmation Page</title>
</head>
<body>
<h1>#{person.name}</h1> from <h2>#{person.city}</h2>
</body>
</html>
Person.java:
package org.demo;
import javax.enterprise.inject.Model;
@Model
public class Person {
String name;
String city;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}