JSF 2.1 & IE Conditional Comments

家住魔仙堡 提交于 2019-12-20 11:29:39

问题


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,


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!