You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Taylor <mi...@google.com> on 2010/09/20 19:16:13 UTC

How to import an externally hosted javscript library?

 Greetings Tapestry Users,

I’m wondering what is the best way for a component class to import an
externally hosted javscript library?

I know that if I want to import a JS file from within my own project I can
use the org.apache.tapestry5.annotations.Import annotation, and tapestry
will make sure that the library is included only once on the page no matter
how many times the component might appear.  However as near as I can tell
the Import annotation will only pull in files off the class path.  Is there
a similar functionality I can use to import a JS library hosted on an
external site or do I just include <script src=”...”> tags in the component
template?

Thanks,

Mike T

Re: How to import an externally hosted javscript library?

Posted by Michael Taylor <mi...@google.com>.
Thank you!  I think that's exactly what I was looking for.

Mike T

On Mon, Sep 20, 2010 at 1:39 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 20 Sep 2010 14:16:13 -0300, Michael Taylor <mi...@google.com>
> wrote:
>
>   Greetings Tapestry Users,
>>
>
> Hi!
>
>
>  I’m wondering what is the best way for a component class to import an
>> externally hosted javscript library?
>>
>
> I haven't had the time to play with Tapestry 5.2 yet (sad!), but you can
> get a JavaScriptSupport instance from the environment and then use the
> importJavaScriptLibrary(String libraryURL) to import an arbitrary JavaScript
> file URL.
>
> @Environmental
> private JavaScriptSupport javaScriptSupport;
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to import an externally hosted javscript library?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 20 Sep 2010 14:16:13 -0300, Michael Taylor <mi...@google.com>  
wrote:

>  Greetings Tapestry Users,

Hi!

> I’m wondering what is the best way for a component class to import an
> externally hosted javscript library?

I haven't had the time to play with Tapestry 5.2 yet (sad!), but you can  
get a JavaScriptSupport instance from the environment and then use the  
importJavaScriptLibrary(String libraryURL) to import an arbitrary  
JavaScript file URL.

@Environmental
private JavaScriptSupport javaScriptSupport;

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org