Here is my xhtml page:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Index</title>
<style>
.error {
background-color: #fdd;
}
</style>
</h:head>
<h:body>
<h:messages style="color: orange" />
<h:form>
<h:inputText value="#{myBacking.um}" required="true" />
<h:commandButton value="Submit" action="#{myBacking.acme}" />
</h:form>
</h:body>
</html>
I tested with mojarra 2.0.9 and mojarra 2.1.8, and both doesn’t generate an id for the h:inputText component.
Is it a bug in JSF?
Mojarra will only set the ID if the enduser has specified it by itself or if the component has client behaviors specified (by
<f:ajax>).Here’s an extract of relevance of the
HtmlBasicRenderersource code:And, note the comments
So, that’s expected behavior.