But what happens when you want it to be javascript?

Then your script would be parsed as EL

An interesting problem

Sent from my Verizon Wireless BlackBerry


From: Werner Punz
Date: Thu, 24 Sep 2009 16:13:58 +0200
To: <jsr-314-open@jcp.org>
Subject: Re: [jsr-314-open] Evaluating EL in resource files

Hello, not sure if I can or am allowed to post, but I am giving it a try.

The -el.js extension seems somewhat strange there is no single equivalent anywhere in  since javascripts are treated like templates, I
would recommend another syntax and leave the el parsing open for any file.

Something along the lines of jsf.el(#{resource['this:scripts.
js']}
) which then is resolved into /jsf-ezcomp02/javax.faces.
resource/scripts.js

jsf.el looks like javascript in this case but is just a directive which means that the embedded expression is an el expression and no javascript.

The parsing then would happen agnostic to any library in before serving.



Werner



On Thu, Sep 24, 2009 at 3:53 PM, Ed Burns <Ed.Burns@sun.com> wrote:
Greetings EG,

We have two problems here.  First, let me restate the intent of the
feature.

FEATURE SHORT DESCRIPTION:
==========================

Let JSF2 resources refer to other resources in a way that the browser
can make GET requests to load them via the ResourceHandler.

RATIONALE for FEATURE:
======================

CSS files may refer to other files using the following syntax

url( some URL )

The url() element may appear in several places in a CSS file, most
commonly to the right of @import, as in

@import url(layout.css)
@import url(typography.css)
@import url(colorAndMedia.css)

Unfortunately, this doesn't "just work" when the CSS file in question is
in a JSF resource library, for obvious reasons.

The solution we chose was to allow EL expressions in CSS files.  That
way, you could say this in your css file:

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

and when the file actually gets served up it would look like:

@import url(/jsf-ezcomp02/javax.faces.resource/layout.css.jsf?ln=ezcomp);
@import url(/jsf-ezcomp02/javax.faces.resource/typography.css.jsf?ln=ezcomp);
@import url(/jsf-ezcomp02/javax.faces.resource/colorAndMedia.css.jsf?ln=ezcomp);

PROBLEM 1. This behavior should have been specified in the javadocs for
Resource.getInputStream().  I've added this to the ChangeLog.

PROBLEM 2.  JavaScript resources have the same problem; they can refer
to other javascript files and the browser needs to know how to fetch
them.  We employed the same solution: put EL in there and it gets
evaluated on the way out.

Unfortunately, the prototype JavaScript library uses #{} to mean
something important.

SUGGESTED SOLUTION to PROBLEM 2.

Let's assume PROBLEM 1 didn't exist.  I suggest we modify the spec for
getInputStream() to say that all resources EXCEPT JavaScript resources,
must do the EL evaluation on the way out.  We need some way for users to
enable the feature for JavaScript resources because, let's face it, not
everyone uses prototype.  Ryan and I suggest we adopt a protocol that
says, "if the resource name ends in '-el' we always turn on the EL
evaluation on the way out".

Thoughts?

Ed

--
| ed.burns@sun.com  | office: 408 884 9519 OR x31640
| homepage:         | http://ridingthecrest.com/