dev@jsf-extensions.java.net

Re: [JSF-EXT] Who has the right to load a script?

From: Gregory Murray <Gregory.Murray_at_Sun.COM>
Date: Mon, 05 Jun 2006 15:03:31 -0700

On Jun 2, 2006, at 7:43 AM, Ed Burns wrote:

> Hello Jsf-extenders,
>
> Consider this example.
>
> Jacob's javax.faces.js avatar library depends on prototype. Using a
> jMaki component that also wraps something in prototype would mean that
> both parties need the prototype.js files, but neither jMaki no avatar
> know about eachother, and therefore they load their own js files as
> needed.

This could cause problems and we should find a way to find out if a
library
has been loaded possibly using a common request scoped attribute. The
other
approach would be to have a way of identifying loaded scripts by looking
for the namespace of that library e.g. if (typeof dojo ==
'undefined') load dojo for
example. This is what we did for the Creator/BluePrints components
and it
worked well. This can be a bit tricky though.

>
> Greg, it looks like jMaki currently punts on the whole resource-
> loading
> thing, requiring the user to put the js files manually in the right
> place in their apps. Jacob, it looks like your demo does the same.

Yes this is the case. I have the hooks in right now to load from the
classpath
but they are not in use yet. When I load resources (CSS/JavaScript/
HTML template
code) I have a lookup path that starts from the current_directory
then goes to the
web_root/resources then to the classpath /META-INF/resources.

This is detailed at:

https://ajax.dev.java.net/jmaki-app.html

The goal is of course to allow for all the resources to be embedded
in the component
and pull them out as needed.


>
> Here's a proposal:
>
> Because jMaki's main value add is its JavaScript wrapper
> capability, and
> because it already has a namespace of sorts for each main javascript
> library, (witness the "type" attribute of the a:ajax component, where
> valid values include "dojo", "scriptaculous", "yahoo", etc), I think
> jMaki is the right place to host this functionality.

I really think this is the best way to go as every library has a
tree, autocomplete,
map, and calendar. The namespacing uses JSAN style directory based
structures like what dojo uses. In my case the name attribute really
refers to
a package (a directory containing a component.js, component.css, and
component.htm).

This keeps the code pretty clean and prevents collisions.

One other concept you all might want to bring in is the direct
linking to resources. I found
this helped me around the context issues. I locate files using the
scheme above then I
put the direct links (I don't use relative links at all) to all
resources.

That said I also do not use image tags anymore for any components as
this can be done
using CSS. I can deep dive into this more if you all like.

-Greg