Simple HTML5 Friendly Markup Sample

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Sat, 26 Oct 2013 21:40:22 +0000 Indexed on 2013/10/26 22:05 UTC
Read the original article Hit count: 230

Filed under:

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;
    }
    
}

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE