[jsr-314-open-mirror] [jsr-314-open] outputStylesheet generates URLs that can't load url(...) in CSS

Ed Burns edward.burns at oracle.com
Mon Sep 13 17:15:27 EDT 2010


>>>>> On Mon, 13 Sep 2010 16:37:16 +0700, Cay Horstmann <cay.horstmann at gmail.com> said:

CH> CSS files commonly contain url(...) expressions such as
CH> .ui-icon { width: 16px; height: 16px; background-image: url(myicon.png); }

CH> These don't work when the CSS file is loaded with

CH> <h:outputStylesheet library="styles" name="skin.css"/>

CH> This discussion explains the problem:
CH> http://forums.sun.com/thread.jspa?threadID=5447194.

CH> It's pretty unsatisfactory that a tag named output*Stylesheet* can't
CH> properly output a style sheet.

CH> One remedy would be for JSF to parse the CSS and rewrite the URLs,
CH> another to have h:outputStylesheet generate a better URL, such as

CH> /context path/javax.faces.resource/styles/skin.css

CH> instead of

CH> /context path/javax.faces.resource/skin.css.xhtml?ln=styles

CH> I realize that the latter would require a spec change in

CH> http://download-llnw.oracle.com/javaee/6/api/javax/faces/application/Resource.html#getRequestPath%28%29

CH> Is this something that is within the scope of JSF 2.0 maintenance? If
CH> not, is there a place to post requests for where the  JSF 2.next
CH> expert group will find it?

I have already specified this in 2.1

The solution is to note that #{} el expressions are evaluated on the way
out when a CSS stylesheet is served up.

Therefore, in the url() syntax you can say something like this:

@import url(#{resource['this:layout.css']});
@import url(#{resource['this:typography.css']});
@import url(#{resource['this:colorAndMedia.css']});

Where "this" is a special keyword that means "the current library".

Or, you can use a literal library name.

Cay,

Can you please share this with the forum?  The JCP changelog for the 2.1
MR is due out within the week, as shown in my .sig here.

Ed

-- 
| edward.burns at oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/
|  5 work days until handoff of JSF 2.1 change log to jcp



More information about the jsr-314-open-mirror mailing list