BTW, you should be able to add a
<c:set var="cp" value="#{facesContext.externalContext.requestContextPath}/>
to your page so you can just write:
body {
background:
url(#{cp}/images/background.jpg);
}
-- Adam
On 6/30/07, Safurudin Mahic <[EMAIL PROTECTED]> wrote:
I simply solved it by doing
<f:view xmlns:f="http://java.sun.com/jsf/core"
contentType="*/*">
<f:verbatim> ....thecss ...</f:verbatim>
</f:view>
It didn't htmlescape my special characters, and now my CSSS is valid
again + I have the power of EL expressions inside CSS
I can now simply use EL expressions to get all the images inside my CSS
files aligned with the context path, which was my main intention;
body {
background:
url(#{facesContext.externalContext.requestContextPath}/images/background.jpg);
}
Probably not the most obvious use-case, but EL expressions offer
functionality which sometimes could be
used beyond the scope of XML-type languages.
Regards,
Safurudin
Adam Winer skrev:
> The issue would be that MyFaces is creating an HtmlResponseWriter
> even though it's not HTML. Hard to blame it, though. The general
> intent here is for XML-type languages.
>
> In this scenario, I'd probably recommend that Facelets
> specifically intercept text/css and text/plain to create
> an internal PlainTextResponseWriter, one that throws
> exceptions on calls to startElement(), for example, but
> passes writeText() straight to write().
>
> -- Adam
>
>
> On 6/29/07, Safurudin Mahic <[EMAIL PROTECTED]> wrote:
>> I'm trying to get facelets to render my css files (especially neet to
>> get the url(#{facesContext.ex
>>
>> Reccomended by some of the guys on the facelets mailing list, I first
>> tried
>> to do <f:view contentType="text/css">...</f:view>
>> This went badly, because the html renderer kit for myfaces doesn't
>> support this contentType. It only support a small set of content types
>> defined;
>> private static String HTML_CONTENT_TYPE = "text/html";
>> private static String TEXT_ANY_CONTENT_TYPE = "text/*";
>> private static String ANY_CONTENT_TYPE = "*/*";
>> private static String APPLICATION_XML_CONTENT_TYPE = "application/xml";
>> private static String TEXT_XML_CONTENT_TYPE = "text/xml";
>> private static String XHTML_CONTENT_TYPE = "application/xhtml+xml";
>>
>> Tried then to use the */* - this went OK - the problem now however is
>> that either facelets or
>> myfaces escapes special characters in the css files:
>>
>> The following perfecly valid css selector:
>>
>> h2 {
>> font-family: Arial, "Arial CE", "Lucida Grande CE", lucida,
>> "Helvetica CE", sans-serif;
>> }
>>
>> is escaped with
>>
>> h2 {
>> font-family: Arial, "Arial CE", "Lucida Grande CE",
>> lucida,
>> "Helvetica CE", sans-serif;
>> }
>>
>> rendering the generated css as invalid
>>
>> Is there a way to turn off html entity character escaping for a
>> particular view?
>>
>> Thanks,
>> Safurudin Mahic
>>
>>