Reputation: 31104
TL;DR: I can't get the DOCTYPE header to appear on my JSF pages.
I just inherited a JSF 1.2 project that's having some display issues under IE. I'm brand new to JSF, but I think the issues stem from the fact that the rendered pages (from "view source") do not contain a proper DOCTYPE
.
The pages are composed of multiple parts, brought together using several layers of <ui:composition>
. A typical page will look like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
template="../layout/template.xhtml">
<ui:define name="body">
<!-- html content goes here... -->
</ui:define>
</ui:composition>
Then the ../layout/template.xhtml
has:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
template="./headertemplate.xhtml">
<ui:define name="menuSelection">
<ui:insert name="menuSelection"/>
</ui:define>
<ui:define name="body">
<ui:insert name="body"/>
</ui:define>
<ui:define name="footer">
<div class="footer">
<ui:include src="footer.xhtml"/>
</div>
</ui:define>
</ui:composition>
And finally, the headertemplate.xhtml
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
contentType="text/html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<body>
<ui:insert name="body" />
</body>
</html>
</ui:composition>
I have left out many xmlns
lines for brevity; I hope you get the idea.
How can I get the DOCTYPE to show up in the rendered pages?
Upvotes: 3
Views: 5351
Reputation: 1109874
Remove <ui:composition>
from your master template, which is the headertemplate.xhtml
. It doesn't belong there. The <ui:composition>
will strip all other content outside the tag.
<!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=UTF-8" />
</head>
<body>
<ui:insert name="body" />
</body>
</html>
Note that the doctype (and xml) declaration is unnecessary in template definition files (the ones using <ui:composition>
). Just remove them.
Upvotes: 7
Reputation: 5552
You must remember one thing, that everything outside ui:compostion tags is simply cut out, so the DOCTYPE declaration in your case is simply ignored.
Upvotes: 1