Skip to main content

JSF Tip #42 - JSF 2.2 HTML 5 passthrough example

Posted by mriem on November 19, 2013 at 12:17 PM PST

In JSF 2.2 it is has been made easier to work together with a HTML designer. The page below exposes a traditional h:inputText and a h:commandButton using a more HTML 5 friendly way of doing this.

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
    <body>
        <form jsf:id="form">
            <p>
                This is a minimal Passthrough sample using HTML5 input types.
                Note if you want JSF to take control of something you will have
                to specify the "jsf:" prefix which was mapped above using the
                "http://xmlns.jcp.org/jsf" namespace.
            </p>
            <input jsf:id="input1" type="tel" jsf:value="12"/>
            <input jsf:id="submit" type="submit" value="Submit"/>
        </form>
    </body>
</html>

Note the code for this sample is available as part of the Glassfish samples (see the subversion repository at https://svn.java.net/svn/glassfish-samples~svn/trunk/ws/javaee7/jsf/passthrough/)

And that is it.

Enjoy!

Related Topics >>