You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joachim Van der Auwera <jo...@progs.be> on 2009/06/17 09:47:40 UTC

integrating jQuery components

Dears,

I see there is a lot of discussion going on about making it possible to 
include jQuery only in tapestry pages.

This seems to be coming from the concern that any pages which include 
jQuery components may include both prototype and jQuery components.

However, in the current state, when you would include two jQuery based 
components from different libraries, you would actually be including 
prototype and two copies of jQuery.

I think the first step would be to assure there is a common jQuery (and 
possibly also other libraries like yiu, dojo,...) which is promoted. 
This way at least that kind of duplication can easily be avoided.

Kind regards,
Joachim

-- 
Joachim Van der Auwera
PROGS bvba, progs.be


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


Re: integrating jQuery components

Posted by Onno Scheffers <on...@piraya.nl>.
>
> In any case, the users should not required to be aware of the javascript
> libraries it uses.
> We only have a limited set of components as is, no use fragmenting this.



End-users shouldn't, but we can expect a little more from developer, right?
:o)

I think most people working with Tapestry, care about quality and
performance. So injecting two different JavaScript frameworks into the HTML
is avoided if possible. This was the main reason I started looking at this
issue in the first place, since I don't like forcing over 160KB of
JavaScript onto the end-users while my own components only require a 56KB
JavaScript framework.

Even the fact that the files are cached on the client doesn't really help,
since you are still letting the other framework use up a lot of resources on
the client by including it. The browser has to parse it all, create models
in memory and existing Elements are extended.


regards,

Onno

Re: integrating jQuery components

Posted by Joachim Van der Auwera <jo...@progs.be>.
Onno Scheffers wrote:
>> I am curious how you managed to include jQuery with
>> @IncludeJavascriptlibrary. I only managed that with a patched version  of
>> jQuery, adding jQuery.noConflict() at the end of the jQuery javascript file.
>> Otherwise there were Javascript bugs...  (using current stable 5.1 Tapestry
>> release)
>>     
>
> This issue only really applies if you are using both Prototype and jQuery in
> your application. I think most people won't want to do that once jQuery is
> officially supported.
>   
I would think that most users just want to use components, some of which 
may use prototype, some of which may use jQuery.

As I said, a proposed way to include jQuery (and possibly other 
libraries) which avoids conflicts (so possibly patched) and duplication 
would make sens in my opinion.

In any case, the users should not required to be aware of the javascript 
libraries it uses.
We only have a limited set of components as is, no use fragmenting this.

Kind regards,
Joachim

-- 
Joachim Van der Auwera
PROGS bvba, progs.be


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


Re: integrating jQuery components

Posted by Onno Scheffers <on...@piraya.nl>.
>
> I am curious how you managed to include jQuery with
> @IncludeJavascriptlibrary. I only managed that with a patched version  of
> jQuery, adding jQuery.noConflict() at the end of the jQuery javascript file.
> Otherwise there were Javascript bugs...  (using current stable 5.1 Tapestry
> release)



This issue only really applies if you are using both Prototype and jQuery in
your application. I think most people won't want to do that once jQuery is
officially supported.

If both Prototype and jQuery are used in your application, then ordering of
the included libraries is imporant.
jQuery assigns itself to the $-variable but stores whatever was in that
variable before. Using jQuery.noConflict(), whatever was in the $-variable
will be put back there.

Internally and in 3rd party jQuery plugins, the $-variable should never be
used, but the jQuery namespace is used instead. The short $-notation is only
there for end-users and can easily be reassigned to something else.

Sadly Prototype and its plugins are not written to work against their own
namespace as far as I can tell. Therefore they rely on the $-var being
assigned to Prototype.

So as soon as the jQuery library is included, the $-variable is assigned to
jQuery. Then some Prototype-libraries are included that depend on the
$-variable being assigned to Prototype. Since it is assigned to jQuery, they
will cause Javascript-errors.

Only after all libraries are included, you get a chance to call
jQuery.noConflict(), which is too late since the JavaScript errors have
already occured.

I also added the jQuery.noConflict()-call to the jquery.js file in my
applications so far.

But this is an area that needs some work when adding jQuery support. By
default, you don't want to force the noConflict-mode onto users, since they
like programming against the $-notation. But if both Prototype and jQuery
are used, or even forced upon you by 3rd party components, then we should
include the jQuery noConflict() call right after jQuery has been included.


regards,

Onno

Re: integrating jQuery components

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,
That's exactly what I'm doing, got the tip from Thiago, I used to directly
include jquery in the tml file, got some unexplained error in browser
lately, switching it to @Include fixes the problem, also preparing my code
for upgrading to t5.1.


Andy Pahne-7 wrote:
> 
> Angelo Chen schrieb:
>> my experience is, safer to use @IncludeJavascriptlibrary to include
>> jQuery,
>> but seems to me that will also pull the Prototype related js too,
>> probably
>> we should have @IncludeJavascriptLib not to include other js.
>>
>>   
> 
> 
> I am curious how you managed to include jQuery with 
> @IncludeJavascriptlibrary. I only managed that with a patched version  
> of jQuery, adding jQuery.noConflict() at the end of the jQuery 
> javascript file. Otherwise there were Javascript bugs...  (using current 
> stable 5.1 Tapestry release)
> 
> Andy
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/integrating-jQuery-components-tp24068609p24070981.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: integrating jQuery components

Posted by Andy Pahne <an...@gmail.com>.
Angelo Chen schrieb:
> my experience is, safer to use @IncludeJavascriptlibrary to include jQuery,
> but seems to me that will also pull the Prototype related js too, probably
> we should have @IncludeJavascriptLib not to include other js.
>
>   


I am curious how you managed to include jQuery with 
@IncludeJavascriptlibrary. I only managed that with a patched version  
of jQuery, adding jQuery.noConflict() at the end of the jQuery 
javascript file. Otherwise there were Javascript bugs...  (using current 
stable 5.1 Tapestry release)

Andy


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


Re: integrating jQuery components

Posted by Angelo Chen <an...@yahoo.com.hk>.
my experience is, safer to use @IncludeJavascriptlibrary to include jQuery,
but seems to me that will also pull the Prototype related js too, probably
we should have @IncludeJavascriptLib not to include other js.


Joachim Van der Auwera wrote:
> 
> Dears,
> 
> I see there is a lot of discussion going on about making it possible to 
> include jQuery only in tapestry pages.
> 
> This seems to be coming from the concern that any pages which include 
> jQuery components may include both prototype and jQuery components.
> 
> However, in the current state, when you would include two jQuery based 
> components from different libraries, you would actually be including 
> prototype and two copies of jQuery.
> 
> I think the first step would be to assure there is a common jQuery (and 
> possibly also other libraries like yiu, dojo,...) which is promoted. 
> This way at least that kind of duplication can easily be avoided.
> 
> Kind regards,
> Joachim
> 
> -- 
> Joachim Van der Auwera
> PROGS bvba, progs.be
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/integrating-jQuery-components-tp24068609p24068871.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: integrating jQuery components

Posted by Massimo Lusetti <ml...@gmail.com>.
On Wed, Jun 17, 2009 at 4:05 PM, Andy Pahne <an...@gmail.com> wrote:

>
> Onno Scheffers schrieb:
>>>
>>> I would prefer: Tapestry uses whatever javascript lib for it's internal
>>> functions. But this "whatever" library should play nice with user's
>>> libraries. (So, prototype, which is in internal use today should be patched
>>> in a way not to hijack $ ).
>>>
>>
>>
>> Sadly that would break pretty much any Prototype plugin :o)
>>
>>
>
>
> Yeah. As Howard once said: "that horse has left the barn a long time ago"....
>

If I'm not mistaken he is referencing prototype's plugins not Tapestry
components.

Cheers
--
Massimo
http://meridio.blogspot.com

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


Re: integrating jQuery components

Posted by Andy Pahne <an...@gmail.com>.
Onno Scheffers schrieb:
>> I would prefer: Tapestry uses whatever javascript lib for it's internal
>> functions. But this "whatever" library should play nice with user's
>> libraries. (So, prototype, which is in internal use today should be patched
>> in a way not to hijack $ ).
>>     
>
>
> Sadly that would break pretty much any Prototype plugin :o)
>
>   


Yeah. As Howard once said: "that horse has left the barn a long time 
ago"....


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


Re: integrating jQuery components

Posted by Onno Scheffers <on...@piraya.nl>.
>
> I would prefer: Tapestry uses whatever javascript lib for it's internal
> functions. But this "whatever" library should play nice with user's
> libraries. (So, prototype, which is in internal use today should be patched
> in a way not to hijack $ ).


Sadly that would break pretty much any Prototype plugin :o)

regards,

Onno

Re: integrating jQuery components

Posted by Andy Pahne <an...@gmail.com>.
I would prefer: Tapestry uses whatever javascript lib for it's internal 
functions. But this "whatever" library should play nice with user's 
libraries. (So, prototype, which is in internal use today should be 
patched in a way not to hijack $ ).

Then users have absolute freedom to use whatever library theyx prefer, 
without patching it


The other point (maybe Tapestry's creator one day decide that lib xy is 
better suited for internal use than yz): an abstraction layer would have 
been usefult for that, but maybe "that horse is out the barn"...

Andy




Joachim Van der Auwera schrieb:
> Dear Onno,
>
> I understand your solution, but that just introduces a second 
> "tapestry supported" javascript library. What if yet another library 
> is better at some point, or some people prefer another one like yui or 
> dojo (remember this was the "preferred" in t4 days, not that long ago).
> Do we really want to include jQuery as well in tapestry itself?
>
> I would suggest having one or more projects on tapestry360 which 
> contain the javascript libraries. These can then be included using 
> @IncludeJavaScriptLibrary and a classpath location (preferably defined 
> as a constant), avoiding the double inclusion.
>
> Kind regards,
> Joachim
>
> Onno Scheffers wrote:
>> The reason that happens is because jQuery isn't officially supported, so
>> each component would ship with jQuery..
>>
>> The way I set things up currently, jQuery is supported like Prototype or
>> Blackbird are supported. So jQuery will be shipped with Tapestry. 
>> This will
>> make sure all component-creators use the same version.
>> They can have it included into the page by using the
>> @IncludeJavaScriptLibrary annotation and a predefined path
>> (tapestry.jquery). Tapestry automatically makes sure only 1 version 
>> is ever
>> included into the page, even if multiple component include it.
>>
>> The double inclusion will only be a problem if you're using different 
>> 3rd
>> party Tapestry components that each also ship with the full plugin. 
>> Then the
>> same library is included twice simply beause they are on different 
>> paths.
>>
>> regards,
>>
>> Onno
>>
>>   
>
>


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


Re: integrating jQuery components

Posted by Massimo Lusetti <ml...@gmail.com>.
On Wed, Jun 17, 2009 at 2:56 PM, Michael Gentry <mg...@masslight.net> wrote:

>
> Some of us create web applications that are on closed networks, too ...
>

Yep that's right, and for the matter I think more then "some".

Regards
--
Massimo
http://meridio.blogspot.com

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


Re: integrating jQuery components

Posted by Michael Gentry <mg...@masslight.net>.
Some of us create web applications that are on closed networks, too ...


On Wed, Jun 17, 2009 at 8:42 AM, Onno Scheffers<on...@piraya.nl> wrote:
> Google already hosts quite a repository of JavaScript framework, so
> theoretically no framework needs to be included in Tapestry at all. It just
> gives you more ease-of-use and control if it is included.

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


Re: integrating jQuery components

Posted by Onno Scheffers <on...@piraya.nl>.
>
> I understand your solution, but that just introduces a second "tapestry
> supported" javascript library. What if yet another library is better at some
> point, or some people prefer another one like yui or dojo (remember this was
> the "preferred" in t4 days, not that long ago).
> Do we really want to include jQuery as well in tapestry itself?



Like discussed earlier, the main point is to isolate Tapestry from
framework-dependencies. Ideally Tapestry wouldn't force any JavaScript
framework onto you, but a good first step is to create the isolation layer
and offer a second framework-specific implementation as a proof-of-concept.
After that nothing is stopping anyone from creating additional support for
other frameworks or even a plain JavaScript implementation.

For now jQuery is the most popular JavaScript framework with an awful lot of
plugins available. A lot of people would like to use it instead of
Prototype.



> I would suggest having one or more projects on tapestry360 which contain
> the javascript libraries. These can then be included using
> @IncludeJavaScriptLibrary and a classpath location (preferably defined as a
> constant), avoiding the double inclusion.



I think the way to distribute it is not up to me. I'm first going to see if
I can isolate things and get it all working in the first place. I am not a
Tapestry committer. I'll just open up my work and then its up to the
committers to decide what to do with it. They can just as well decide not to
do anything with it altogether.

Google already hosts quite a repository of JavaScript framework, so
theoretically no framework needs to be included in Tapestry at all. It just
gives you more ease-of-use and control if it is included.

regards,

Onno

Re: integrating jQuery components

Posted by Joachim Van der Auwera <jo...@progs.be>.
Dear Onno,

I understand your solution, but that just introduces a second "tapestry 
supported" javascript library. What if yet another library is better at 
some point, or some people prefer another one like yui or dojo (remember 
this was the "preferred" in t4 days, not that long ago).
Do we really want to include jQuery as well in tapestry itself?

I would suggest having one or more projects on tapestry360 which contain 
the javascript libraries. These can then be included using 
@IncludeJavaScriptLibrary and a classpath location (preferably defined 
as a constant), avoiding the double inclusion.

Kind regards,
Joachim

Onno Scheffers wrote:
> The reason that happens is because jQuery isn't officially supported, so
> each component would ship with jQuery..
>
> The way I set things up currently, jQuery is supported like Prototype or
> Blackbird are supported. So jQuery will be shipped with Tapestry. This will
> make sure all component-creators use the same version.
> They can have it included into the page by using the
> @IncludeJavaScriptLibrary annotation and a predefined path
> (tapestry.jquery). Tapestry automatically makes sure only 1 version is ever
> included into the page, even if multiple component include it.
>
> The double inclusion will only be a problem if you're using different 3rd
> party Tapestry components that each also ship with the full plugin. Then the
> same library is included twice simply beause they are on different paths.
>
> regards,
>
> Onno
>
>   


-- 
Joachim Van der Auwera
PROGS bvba, progs.be


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


Re: integrating jQuery components

Posted by Onno Scheffers <on...@piraya.nl>.
>
> However, in the current state, when you would include two jQuery based
> components from different libraries, you would actually be including
> prototype and two copies of jQuery.
>
> I think the first step would be to assure there is a common jQuery (and
> possibly also other libraries like yiu, dojo,...) which is promoted. This
> way at least that kind of duplication can easily be avoided.



The reason that happens is because jQuery isn't officially supported, so
each component would ship with jQuery..

The way I set things up currently, jQuery is supported like Prototype or
Blackbird are supported. So jQuery will be shipped with Tapestry. This will
make sure all component-creators use the same version.
They can have it included into the page by using the
@IncludeJavaScriptLibrary annotation and a predefined path
(tapestry.jquery). Tapestry automatically makes sure only 1 version is ever
included into the page, even if multiple component include it.

The double inclusion will only be a problem if you're using different 3rd
party Tapestry components that each also ship with the full plugin. Then the
same library is included twice simply beause they are on different paths.

regards,

Onno