Question

I include a header.html (not .xhtml) to my page, but when I preview my page, it give me error "XML Parsing Error: no element found". I do know that it is the tag no properly closed issue, but since my header page is a html file, not a xhtml file, it shouldn't must close the tag, am I right?
If I do close all the meta tag in my header.html, my page is working fine, but I wish to know that is it a must close all the tag properly in html file if I include them in jsf2, thanks.

header.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Header</title>
    <meta name="description" content="">
  </head>
  <body>header content</body>
</html>

welcome1.xhtml

<ui:include src="header.html" />
<p>welcome page</p>
Was it helpful?

Solution

From Oracle's documentation, <ui:include> is used to encapsulate and reuse content among multiple XHTML pages. The src attribute is expected to point to a well-formed XML document. Even if you want to include .html pages, you need to make sure all tags are closed properly.

OTHER TIPS

If you look more closely, you will see the closing <html> tag in you header.html, which should end the HTML document, as you can see in Structure of an HTML document. This way, when you include the file in the final view you break that contract.

In JSF you'd be better off using the templating option of facelets. For example in a master template you can make insert points, like the scripts section, and later define inserted contents in template client pages (final views). Kickoff example can be found in this tutorial by mkyong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top