Have xhtml templ.xhtml layout.
Include it to other .xhtml like:
<ui:composition template="/template/templ.xhtml">
Define conditionals in templ.xhtml like:
<h:head>
<h:outputText value="<!--[if lt IE 8]><h:outputStylesheet library="css" name="styleie8.css" /><![endif]-->" escape="false" />
</h:head>
styleie8.css is not loaded,but when something changed and saved in templ.xhtml when Tomcat is running,that it loaded ok.
How to do,that JSF loads conditionals immediately when Tomcat started?
Note:
tried to use following alternatives:
1.
<!--[if lt IE 8]>
<h:outputStylesheet name="styleie8.css" library="css"/>
<![endif]-->
2.
<o:conditionalComment if="lte IE 8">
<link rel="stylesheet" href="styleie8.css" />
</o:conditionalComment>
3. #{request.contextPath}/resources instead of simple path.
The result is the same – I need resave .xhtml template in order to load conditionals css.
Your initial code snippet is wrong. You can’t print a
<h:outputStylesheet>in a<h:outputText escape="false">. The<h:outputStylesheet>is a JSF component which is supposed to generate HTML, but in a<h:outputText escape="false">it would be printed literally as-is. If you open the page in browser and do rightclick, View Source, then you should have discovered this yourself. This is not right. The webbrowser understands only HTML which should be<link rel="stylesheet">.Provided that you’ve placed the stylesheet in
/resources/css/styleie8.css, then the following should work:As to the alternatives you tried, 1) would not work as it would be escaped. 2) should work assuming that the
hrefpoints to the right URL. In the example as you’ve posted, it assumes the CSS file to be in the same folder as the view. However, if it is still located in/resources/css/styleie8.css, then you should have used:3) should work, assuming that you provided the right URL.