I've noticed that in JSF 2.1.* my IE conditional comments are no longer working. Various characters are being replaced by HTML entities & invalidating the comment syntax. BalusC has pointed out a solution to the problem in another question which uses h:outputText. My problem is that I want my conditional comments at the top of my page, around the first element. This means that I can't use h:outputText as I haven't defined it's namespace yet. I believe that's correct anyway. Here's a code example.
Most by JSF pages nowadays will start off with a template similar to the HTML5 Boilerplate syntax:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 my-application" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 my-application" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9 my-application" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js my-application" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" lang="en"><!--<![endif]-->
<h:head>
<meta charset="utf-8" />
...
With BalusC's mentioned solution, I'd want <h:outputText />
on line 2 but the h namespace isn't defined yet. Is that an element I can use that I can attach the various namespaces to but won't affect my final HTML? Any other ideas how I can get round this issue?
Lee,
Wrap it all in a <f:view>
and define the namespaces there.
<!DOCTYPE html>
<f:view xmlns="http://www.w3.org/1999/xhtml" ...>
...
</f:view>
The entire JSF view is otherwise already implicitly wrapped in a <f:view>
.
来源:https://stackoverflow.com/questions/10616944/jsf-2-1-ie-conditional-comments