Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2.1 & IE Conditional Comments

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,

like image 334
Lee Theobald Avatar asked May 16 '12 10:05

Lee Theobald


1 Answers

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>.

like image 105
BalusC Avatar answered Nov 08 '22 17:11

BalusC