Really a great description in as much detail as possible in a mailing list!
I'll try this idea, but in the mean while I have worked on something of a
Filter which will inject the resource links into every page in the web app .
I have two things:
1. A filter which captures the response
and injects a <script type="text/javascript" src="company/sripts.js">
</script>
2. A PhaseListener which will load the
resources in the after render response phase.
It is working fine, but are there any issues I need to take care of, apart
from Caching the resources on the browser?
I believe that what trinidad has done will be a
better thing because You people might have taken a lot of things into
consideration, and thoroughly tested the code on several fronts, but I want
to know what more can I do to improve the performance of the
approach I'm taking.
It's more of a challenge to me than a requirement...
So, if you can suggest some areas where I need to apply caution , I 'll be
very much grateful to you....
Thanking you,
Samba
On Jan 23, 2008 11:10 PM, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>
>
> >From: "Andrew Robinson" <[EMAIL PROTECTED]>
> >Looks like something dying to be in the WIKI Gary :)
> >
>
> Not a bad idea. I'll see what I can do.
>
> >-Andrew
> >
>
> Gary
>
> On Jan 23, 2008 10:28 AM, Gary VanMatre <[EMAIL PROTECTED]> wrote:
>
> > >From: Samba <[EMAIL PROTECTED]>
> > >Hi all,
> > > I'm building a couple of custom components based on trinidad core,
> > more like adding some
> > >enhancements...
> > >
> > > I would like to know if Trinidad expose any API to be used by Coustom
> > components to load our
> > >own JavaScript, CSS , and Images.
> > >
> >
> > You can plug in a custom script loaders into a web application that
> > already uses trinidad. Trinidad uses a resource servlet. At startup, the
> > resource servlet scanns the class path for
> > META-INF/services/resources/{url-pattern}.resources. These
> > files define resource loaders.
> >
> > Steps:
> > 1) Create a trinidad resource loader by extending RegexResourceLoader.
> >
> > <code>
> > /**
> > * <p>This is a composite resource loader that hooks into the
> > * <code>ResourceServlet</code>.
> > * <pre>
> > * <servlet>
> > * <servlet-name>resources</servlet-name>
> > * <servlet-class>
> > org.apache.myfaces.trinidad.webapp.ResourceServlet
> > * </servlet-class>
> > * </servlet>
> > * </pre><br/><br/>
> > *
> > * It is registered by placing a text file under
> > * the "/META-INF/servlets/resources" folder. The name of the file must
> > * begin with the url folder prefix registered in the web deployment
> > * descriptor (web.xml) and the suffix should be ".resources".
> > *
> > * <pre>
> > *<servlet-mapping>
> > * <servlet-name>resources</servlet-name& amp;gt ;
> >
> > & nbsp;* <url-pattern>/acme/*</url-pattern>
> > *</servlet-mapping>
> > * </pre><br/><br/>
> > *
> > * The folder prefix needs to correspond to the formulation of various
> > * web resources.
> > *
> > *<pre>
> > * #{facesContext.externalContext.requestContextPath
> > }/acme/images/folder.gif}
> > *</pre>
> > *
> > *
> > *
> > */
> > public class AcmeResourceLoader
> > extends RegexResourceLoader
> > {
> > public AcmeResourceLoader()
> > {
> > // any resource in "/acme/" with the following suffixes will be
> > // loaded from the base folder of "META-INF".
> > // The servlet pattern match "/acme/*" should exist under
> > "META-INF".
> > // For example URL : context-root/acme/images/type1.gif
> > // map to: META-INF/acme/images/type1.gif
> > register("(/.*\\.(jpg|gif|png|jpeg))",
> > new ClassLoaderResourceLoader("META-INF"));
> > // associate pattern match on the "/acme/all-acme.js" to deliver
> > // all JS files bundled by the AcmeScriptsResourceLoader
> > register("(/.*all-acme.js)",
> > new AcmeScriptsResourceLoader("/acme/all- acme.js"));
> > }
> >
> > /**
> > * <p>Aggregates all JavaScript files into a single stream identified
> > * by a single URI. All JavaScripts for the acme custom component
> > library
> > * will be delivered using a single script include.
> > *
> > * <pre>
> > * <script type="text/javascript"
> > * scr="#{facesContext.externalContext.requestContextPath}/acme/all-
> > acme.js"
> > * />
> > * </pre>
> > * <br/>
> > * -- or --
> > * <pre>
> > * <trh:script source="/acme/all-acme.js"/>
> > * </pre>
> > * </p>
> > */
> > public static class AcmeScriptsResourceLoader
> > extends AggregatingResourceLoader
> > {
> > /**
> > * <p>The URI used to identify all of the JavaScripts that will be
> > * included using a single URI.</p>
> > *
> > * @param scriptsURI the URI relative to "/acme/*"
> > */
> > public AcmeScriptsResourceLoader(String scriptsURI)
> > {
> > // pass the base folder and list of script files.
> > // the script files have to be within the classpath
> > super(scriptsURI, _LIBRARIES, new ClassLoaderResourceLoader());
> > this.setSeparator(AcmeScriptsResourceLoader._NEWLINE_SEPARATOR);
> > }
> > /**
> > * <p>List of all JavaScript files to include. The Peer JS
> > * file should always be registered last for a component
> > * grouping if the peeer is registered with the component
> > * in the peer JS file.</p>
> > */
> > static private final String[] _LIBRARIES =
> > { "oracle/adfdemo/acme/js/component/AcmeTagPane.js",
> > "oracle/adfdemo/acme/js/event/AcmeTagSelectEvent.js",
> > "oracle/adfdemo/acme/js/component/AcmeTagPanePeer.js" };
> > /**
> > * <p>The separator to use in between streams.</p>
> > */
> > static private final String _NEWLINE_SEPARATOR = "\n";
> > }
> >
> > }
> > </code>
> >
> > 2) Create a simple registration file
> > (META-INF/services/resources/acme.resources) in the jar or web
> > project containing the fully qualifed path to the resource loader.
> >
> > <code>
> > oracle.adfdemo.acme.faces.resource.AcmeResourceLoader
> > </code>
> >
> > 3) Add the resource servlet mappings to your web deployment descriptor (
> > web.xml).
> >
> > <code>
> > <servlet-mapping>
> > <servlet-name>resources</servlet-name>
> > <url-pattern>/acme/*</url-pattern>
> > </servlet-mapping>
> > </code>
> >
> > 4) Include the script in the jsp page.
> >
> > <code>
> > <trh:head>
> > <trh:script source="/acme/all-acme.js"/>
> > </trh:head>
> > </code>
> >
> >
> > >Any help in this regard is highly appreciated,
> > >Thanking you all,
> > >Samba
> >
> > Gary
> >
> >
>
--
Regards...
Samba.