Search code examples
cssjsfmanaged-beandynamically-generated

Generate CSS from JSF managed bean


I have this CSS code:

td[data-date='2016-03-08']{
  background-color: #F7F7F7;
}

I want to apply it on several dates that I want to load from a database. All this could happen inside my JSF managed bean where I generate the CSS code.

So my question is, how can I apply the CSS that I'm gonna get from my JSF managed bean?


Solution

  • One way is to print it as body of HTML <style> tag which you put in HTML head.

    <h:head>
        ...
        <style>#{bean.css}</style>
    </h:head>