[jsr-314-open] Evaluating EL in resource files

Werner Punz werner.punz at gmail.com
Thu Sep 24 10:13:58 EDT 2009


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 at 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 at sun.com  | office: 408 884 9519 OR x31640
> | homepage:         | http://ridingthecrest.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20090924/1ccd716d/attachment.html 


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