Net support for HTML 5 tags in JSF 2

I want to use plain HTML 5 in my JSF page, as some user interface features cannot be achieved thanks to the HTML support provided by JSF2.


In JSF 2.0, some HTML 5 form element attributes cannot be correctly displayed in standard JSF input components.

For example, <input type="email"can not be displayed <h:inputText type="email".

In the link below, they used some pure HTML 5 tags, such as <canvas> <header> <footer> <small>etc.

Now my questions are:

  • When I try to use a clean html input tag with type “text” on my JSF page, I cannot get the value from my managed Bean and set it to this text box. why the value is not displayed?

  • An xhtml page only supports some simple HTML 5 tags, or all HTML 5 tags are supported

+4
source share
1 answer

HTML5 support was added in JSF2.2 . From then on, you can add Passthrough attributes to JSF-Components:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://java.sun.com/jsf/passthrough">
  <h:form>
    <h:inputText p:type="email" />
  </h:form>
</html>

Attributes that are unknown will be ignored by JSF (2.0 and 2.2). If you need to render HTML5 attributes using JSF2.0, you can use Omnifaces HTML5 Renderkit .

Pure HTML tags are just pure HTML tags. They are not JSF components. This way they will appear in the view, but JSF does not care about them and will not update your model.

JSF2.2 Passthrough Elements. HTML- JSF-:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:jsf="http://java.sun.com/jsf" 
  xmlns:f="http://java.sun.com/jsf/core">
  <input jsf:id="foo" type="text" jsf:value="#{bean.bar}">
</html>

JSF , UIComponent HTML- h: inputText. UIComponent JSF , ajax.

: JSF 2.2: HTML5

+9

Source: https://habr.com/ru/post/1540158/


All Articles