HTML 5 support in JSF 2.2

HTML 5 support is provided in JSF 2.2

About this task

The JSF 2.2 specification defines a way to mix JSF code with plain HTML5 by adding new namespaces:
  • http://xmlns.jcp.org/jsf/passthrough
  • http://xmlns.jcp.org/jsf
These namespaces are automatically added to JSF 2.2 projects and enable you to:
  • Use HTML attributes in JSF components (Pass-through attributes).
  • Use JSF attributes in HTML tags (Pass-through elements).
Using these new namespaces, you are also able to write fully-compliant JSF pages using only HTML. HTML5 introduces a series of new attributes for existing elements with JSF 2.2, and you can mix those attributes with JSF components by using the content assist in the source editor or using the Properties view:

Procedure

  1. Pass-through attributes
    1. In the Design or Source view, select a JSF component. The Properties view displays the available HTML5 attributes for the selected JSF component in the HTML5 section:
      html5 select JSF component
    2. Alternatively, you can use the editor Content assist:
      • Place the cursor inside a component.
      • Type the prefix of the Pass-through attributes namespace (by default it is"p:"):
        pass-through attribute
      • Press Ctrl+Space to launch the Content Assist and select one of the available JSF attributes:
        HTML5 attributes
      • 3.The JSF attribute is added to the HTML element:
        JSF attribute added
  2. Pass-through elements: As well as the ability to inject HTML5 attributes into JSF components, you can also inject JSF attributes into HTML tags using the content assist in the source editor or using the Properties view.
    1. In the Design or Source view, select an HTML element.
    2. The Properties view displays the available JSF attributes for the selected HTML element in the HTML5 section:
      pass-through elements
    3. Alternatively, you can o use the editor Content assist:
      • Place the cursor inside a component.
      • Type the prefix of the Pass-through elements namespace (by default it is "jsf:"):
        pass-through elements content assist
      • Press Ctrl+Space to launch the Content Assist and select one of the available JSF attributes:
        autocomplete
      • The JSF attribute is added to the HTML element:
        autocomplete value

Feedback