What are the namespaces for "h", "f", ... in a JSF page for Jakarta EE 9?
Asked Answered
K

1

10

I tried xmlns:h="jakarta.faces.html", xmlns:h="http://jakarta.faces.html", xmlns:h="https://jakarta.faces.html" and other similar strings, but nothing seems to work.

Kilpatrick answered 19/7, 2021 at 10:7 Comment(0)
G
15

The xmlns:h="jakarta.faces.html" is introduced in Faces 4.0, part of Jakarta EE 10.

In JSF 3.0, part of Jakarta EE 9, it is still xmlns:h="http://xmlns.jcp.org/jsf/html".

Summary of API packages and XML namespace URIs to use:

  • J2EE 1.4 / JSF 1.0-1.1: javax.faces.* and http://java.sun.com/jsf/*
  • Java EE 5 / JSF 1.2: javax.faces.* and http://java.sun.com/jsf/*
  • Java EE 6 / JSF 2.0-2.1: javax.faces.* and http://java.sun.com/jsf/*
  • Java EE 7 / JSF 2.2: javax.faces.* and http://xmlns.jcp.org/jsf/*
  • Java EE 8 / JSF 2.3: javax.faces.* and http://xmlns.jcp.org/jsf/*
  • Jakarta EE 8 / JSF 2.3: javax.faces.* and http://xmlns.jcp.org/jsf/*
  • Jakarta EE 9 / JSF 3.0: jakarta.faces.* and http://xmlns.jcp.org/jsf/*
  • Jakarta EE 10 / Faces 4.0: jakarta.faces.* and jakarta.faces.*

Noted should be that the XML namespace URIs are backwards compatible in each newer version. So in e.g. Faces 4.0 you can still use the http://java.sun.com/jsf/* and http://xmlns.jcp.org/jsf/* URIs next to jakarta.faces.*. But this is clearly not recommended as support for old URIs are still prone to be removed sometime in the future and any new components/tags introduced for the first time in a newer URI are not necessarily available via older URIs.

Faces 4.0 is the first version to use a URN instead of URL as XML namespace URI. So the URL-form with http(s):// prefix is invalid. The reason for using a URN instead of URL is because those taglib URIs are in first place not available as physical web resources returning some sort of XSD file and therefore caused confusion among starters. Moreover, URNs are more future-proof as you don't necessarily need to include a hostname such as java.sun.com or xmlns.jcp.org which are more sensitive to change of name/owner than an API name.

See also:

Gasometry answered 19/7, 2021 at 11:30 Comment(5)
Thanks BalusC for your detailed answer.Kilpatrick
Thanks BalusC. The 'and' in the JSF 3.0 statement "Jakarta EE 9 / JSF 3.0: jakarta.faces.* and xmlns.jcp.org/jsf*" for the new jakarta.faces.* namespaces doesn't seem to function upon testing at least using Eclipse IDE. Did I possibly miss something?Durware
Not a JSF problem. Ask to Eclipse instead.Gasometry
Thank you BalusC. I did ask Eclipse bugs.eclipse.org/bugs/show_bug.cgi?id=581893. The answer was Eclipse "does not support Jakarta Faces (i.e. JSF with Jakarta namespace) at all". Can you say which IDE you use that does have support for Jakarta projects?Durware
@Ted: To be more precise, the Eclipse WTP (web tools plugin) does not yet support Faces 4. The idea is to ask them to add support for Faces 4. The repo is at github.com/eclipse-jsf/webtools.jsf Create issue over there, or fork it and add it yourself and manually update the plugin.Gasometry

© 2022 - 2024 — McMap. All rights reserved.