You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2012/01/13 00:31:16 UTC

how/where is tapestry.js included?

Hi all,

I recently figured out that 'tapestry.js', 'prototype.js' etc is only 
included when you have at least one tapestry component within a tml.

I can't find where this logic takes place however.

I need to make use of prototype and tapestry js on a page which does not 
have any tapesry components and want to figure out the simplest way of 
including them.

Thanks, Paul.

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


Re: how/where is tapestry.js included?

Posted by Paul Stanton <pa...@mapshed.com.au>.
Got it.

So as soon as you @Import a library, the stack comes down too.

Thanks.

On 13/01/2012 12:04 PM, Howard Lewis Ship wrote:
> Basically, when your code invokes most methods of JavaScriptSupport
> (or, in older versions of Tapestry, RenderSupport) that triggers the
> inclusion of the "core" JavaScriptStack. "core" is "tapestry.js" plus
> supporting libraries such as prototype.js.  This intent is that, if
> you are not using JavaScript on a page, you don't force the browser to
> load all that JavaScript.
>
> So, for example, if you page has some JavaScript associated with it,
> package that into a companion JavaScript file (I usually name it the
> same as the Java class, but with a different extension), thus:
>
> @Import("library=NiftyPage.js")
> public class NiftyPage { ...
>
> Now Tapestry's core stack, including prototype&  scriptaculous, is
> loaded as well as your JavaScript.
>
> This is better than inline<script>  elements, from a bunch of
> performance and maintainability points of view.
>
> On Thu, Jan 12, 2012 at 3:38 PM, Lenny Primak<lp...@hope.nyc.ny.us>  wrote:
>> I would look at the source code of the simplest tapestry component to see how it does it.
>>
>>
>>
>> On Jan 12, 2012, at 6:31 PM, Paul Stanton<pa...@mapshed.com.au>  wrote:
>>
>>> Hi all,
>>>
>>> I recently figured out that 'tapestry.js', 'prototype.js' etc is only included when you have at least one tapestry component within a tml.
>>>
>>> I can't find where this logic takes place however.
>>>
>>> I need to make use of prototype and tapestry js on a page which does not have any tapesry components and want to figure out the simplest way of including them.
>>>
>>> Thanks, Paul.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>

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


Re: how/where is tapestry.js included?

Posted by Chris Mylonas <ch...@opencsta.org>.
It looks like Howard's example is like approach 1 here http://tapestry.apache.org/javascript.html

The @Import annotation when used with the element "library" as shown in his response is for js libraries.  Same as "stack".
For use with a stylesheet, use the element "stylesheet"

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Import.html

Good question & answer for a Friday :)



On 13/01/2012, at 12:04 PM, Howard Lewis Ship wrote:

> Basically, when your code invokes most methods of JavaScriptSupport
> (or, in older versions of Tapestry, RenderSupport) that triggers the
> inclusion of the "core" JavaScriptStack. "core" is "tapestry.js" plus
> supporting libraries such as prototype.js.  This intent is that, if
> you are not using JavaScript on a page, you don't force the browser to
> load all that JavaScript.
> 
> So, for example, if you page has some JavaScript associated with it,
> package that into a companion JavaScript file (I usually name it the
> same as the Java class, but with a different extension), thus:
> 
> @Import("library=NiftyPage.js")
> public class NiftyPage { ...
> 
> Now Tapestry's core stack, including prototype & scriptaculous, is
> loaded as well as your JavaScript.
> 
> This is better than inline <script> elements, from a bunch of
> performance and maintainability points of view.
> 
> On Thu, Jan 12, 2012 at 3:38 PM, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
>> I would look at the source code of the simplest tapestry component to see how it does it.
>> 
>> 
>> 
>> On Jan 12, 2012, at 6:31 PM, Paul Stanton <pa...@mapshed.com.au> wrote:
>> 
>>> Hi all,
>>> 
>>> I recently figured out that 'tapestry.js', 'prototype.js' etc is only included when you have at least one tapestry component within a tml.
>>> 
>>> I can't find where this logic takes place however.
>>> 
>>> I need to make use of prototype and tapestry js on a page which does not have any tapesry components and want to figure out the simplest way of including them.
>>> 
>>> Thanks, Paul.
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


Re: how/where is tapestry.js included?

Posted by Howard Lewis Ship <hl...@gmail.com>.
Basically, when your code invokes most methods of JavaScriptSupport
(or, in older versions of Tapestry, RenderSupport) that triggers the
inclusion of the "core" JavaScriptStack. "core" is "tapestry.js" plus
supporting libraries such as prototype.js.  This intent is that, if
you are not using JavaScript on a page, you don't force the browser to
load all that JavaScript.

So, for example, if you page has some JavaScript associated with it,
package that into a companion JavaScript file (I usually name it the
same as the Java class, but with a different extension), thus:

@Import("library=NiftyPage.js")
public class NiftyPage { ...

Now Tapestry's core stack, including prototype & scriptaculous, is
loaded as well as your JavaScript.

This is better than inline <script> elements, from a bunch of
performance and maintainability points of view.

On Thu, Jan 12, 2012 at 3:38 PM, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> I would look at the source code of the simplest tapestry component to see how it does it.
>
>
>
> On Jan 12, 2012, at 6:31 PM, Paul Stanton <pa...@mapshed.com.au> wrote:
>
>> Hi all,
>>
>> I recently figured out that 'tapestry.js', 'prototype.js' etc is only included when you have at least one tapestry component within a tml.
>>
>> I can't find where this logic takes place however.
>>
>> I need to make use of prototype and tapestry js on a page which does not have any tapesry components and want to figure out the simplest way of including them.
>>
>> Thanks, Paul.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: how/where is tapestry.js included?

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I would look at the source code of the simplest tapestry component to see how it does it. 



On Jan 12, 2012, at 6:31 PM, Paul Stanton <pa...@mapshed.com.au> wrote:

> Hi all,
> 
> I recently figured out that 'tapestry.js', 'prototype.js' etc is only included when you have at least one tapestry component within a tml.
> 
> I can't find where this logic takes place however.
> 
> I need to make use of prototype and tapestry js on a page which does not have any tapesry components and want to figure out the simplest way of including them.
> 
> Thanks, Paul.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

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


Re: how/where is tapestry.js included?

Posted by Robert Zeigler <ro...@roxanemy.com>.
The inclusion by components is a side-effect. You can trigger the auto-inclusion without a component by using code that depends on the stack. In particular, if you call JavaScriptSupport.addInitializerCall, JavaScriptSupport.addScript, if you import a library (via annotation or directly via JavaScriptSupport.importJavaScriptLibrary), or you import another stack (by annotation of via JavaScriptSupport.importStack), tapestry will import the full tapestry stack (tapestry.js, prototype.js, etc.) for you. 

Robert

On Jan 12, 2012, at 1/125:31 PM , Paul Stanton wrote:

> Hi all,
> 
> I recently figured out that 'tapestry.js', 'prototype.js' etc is only included when you have at least one tapestry component within a tml.
> 
> I can't find where this logic takes place however.
> 
> I need to make use of prototype and tapestry js on a page which does not have any tapesry components and want to figure out the simplest way of including them.
> 
> Thanks, Paul.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


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