Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:46:16+00:00 2026-06-08T18:46:16+00:00

What i want to do in my JSF 2 application is to set proper

  • 0

What i want to do in my JSF 2 application is to set proper html style depending on browser version, here is sample code:

<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <!--<![endif]-->

How to do that in JSF 2? What is the best/simplest way?

I found something interesting in Omnifaces (o:conditionalComment) but it only allows conditional loading of entire css which is useless for me…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:46:18+00:00Added an answer on June 8, 2026 at 6:46 pm

    It’s not true that the <o:conditionalComment> is for CSS files only. That’s a misconception. It’s technically simply not possible to achieve your requirement with pure Facelets tags/components as it would result in malformed XML syntax and thus a Facelets compile error.

    <o:conditionalComment if="lt IE 7">
        <html lang="en" class="lt-ie9 lt-ie8 lt-ie7">
    </o:conditionalComment>
    <o:conditionalComment if="IE 7">
        <html lang="en" class="lt-ie9 lt-ie8">
    </o:conditionalComment>
    <o:conditionalComment if="IE 8">
        <html lang="en" class="lt-ie9">
    </o:conditionalComment>
    <o:conditionalComment if="gt IE 8">
        <h:outputText value="&lt;!--&gt;" escape="false" />
        <html lang="en" class="no-js">
        <h:outputText value="&lt;!--" escape="false" />
    </o:conditionalComment>
    ...
    </html>
    

    This is not well formed XML. You know, the XML end element should be in the very same scope as XML start element. It would be valid XML if every <html> has its own </html> in the same parent XML element. But this is in turn not valid HTML.

    Just use <h:outputText escape="false"> on all <html> tags. Don’t forget to do the same for the closing </html> tag.

    <o:conditionalComment if="lt IE 7">
        <h:outputText value="&lt;html lang=&quot;en&quot; class=&quot;lt-ie9 lt-ie8 lt-ie7&quot;&gt;" escape="false" />
    </o:conditionalComment>
    <o:conditionalComment if="IE 7">
        <h:outputText value="&lt;html lang=&quot;en&quot; class=&quot;lt-ie9 lt-ie8&quot;&gt;" escape="false" />
    </o:conditionalComment>
    <o:conditionalComment if="IE 8">
        <h:outputText value="&lt;html lang=&quot;en&quot; class=&quot;lt-ie9&quot;&gt;" escape="false" />
    </o:conditionalComment>
    <o:conditionalComment if="gt IE 8">
        <h:outputText value="&lt;!--&gt;&lt;html lang=&quot;en&quot; class=&quot;no-js&quot;&gt;&lt;!--" escape="false" />
    </o:conditionalComment>
    ...
    <h:outputText value="&lt;/html&gt;" escape="false" />
    

    Pretty awkward, but the HTML5 boilerplate (where this approach originated) is at its whole own also awkward, IMO.

    Alternatively, you could consider creating a custom <my:html> component yourself which generates the desired markup so that you can just suffice with <my:html>...</my:html>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display primefaces pie chart in my JSF application. Here is my
I want to update my JSF application to use Mojarra version 2.1.8. I added
I am developing a JSF application with JPA(EclipseLink 2.0) and Primefaces. I want to
I have a Java-JSF Web Application on GlassFish, in which I want to use
I'm running a JSF 2.0 application on Tomcat 7. I want to use javascript
I want to upgrade my web application to the latest JSF Mojarra (2.1.9 as
I've created a JSF application, and I want to embed a link in a
I want to upload a file with AJAX in a JSF application. The idea
I have a legacy JSF application. Now that we want to add i18n support
In my JSF/Facelets application, I want to dynamically generate a breadcrumb trail from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.