2

I'm trying to learn JSF for a project I have in my internship, and I'm really struggling.

Can anyone explain why in this piece of code I am getting an "Unknown tag" warning for h:outputLabel?

Thank you!

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0      Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>

    <h:outputLabel value ="Welcome #{loginbean.name}"></h:outputLabel>

</body>
</html>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user2019260
  • 143
  • 4
  • 10

1 Answers1

7

Because you forgot to declare the h: XML namespace.

Add that XML namespace to your <html> element.

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html">

See also:


Unrelated to the concrete problem, the <h:outputLabel> generates a HTML <label> element, with the intent to label HTML input elements. You seem to want to display some text only. In that case you are actually using the wrong element and you should be using <h:outputText>.

<h:outputText value="Welcome #{loginbean.name}" />

Or even better, just use EL in template text. This was not supported in JSF 1.x, but this is supported in JSF 2.x on Facelets.

Welcome #{loginbean.name}

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555