Ed, the hardship with your proposed solution is that the CSS has to be
edited. That's not something that people will always want to do. Like
I said, when the tag is called h:outputStylesheet, there is a
reasonable expectation that you can serve up a style sheet.
In my current project, for example, the style sheet is automagically
generated by some theme engine whatsit, and I don't want to touch it
because I don't begin to understand it :-)
My remedy was to use
<link type="text/css" rel="stylesheet"
href="#{request.contextPath}/skins/cupertino/skin.css"/>
It works for me because I can include that in a template, and there is
no relocation problem. But it's not going to work for everyone--after
all, that's why h:outputStylesheet was invented in the first place.
I think this deserves a more serious solution, either by changing the
URLs for resource retrieval, or by rewriting url(,,,) when serving up
the CSS.
NB. There is also the unpleasant issue of the resource localization
that I keep kvetching about. Is a fix for that in the works?
Cheers,
Cay
On Tue, Sep 14, 2010 at 4:15 AM, Ed Burns <edward.burns(a)oracle.com> wrote:
>>>>> On Mon, 13 Sep 2010 16:37:16 +0700, Cay Horstmann
<cay.horstmann(a)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/Reso...
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(a)oracle.com | office: +1 407 458 0017
| homepage: |
http://ridingthecrest.com/
| 5 work days until handoff of JSF 2.1 change log to jcp