You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by iberck <ib...@gmail.com> on 2010/11/12 09:48:06 UTC

Tapestry 5.1.0.5 repit the scripts

Hi dear tapestry users:

I don't know if it is a bug or if it affects above versions but when I add a
script (jquery) in my layout component and then I add the same script
(jquery) in a mixin, the generated html has the same script (jquery) 2 times

I spend some time to discover this problem because I'm creating jquery
mixins
I'm debugging with firebug

Regards

-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-1-0-5-repit-the-scripts-tp3261634p3261634.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: Tapestry 5.1.0.5 repit the scripts

Posted by iberck <ib...@gmail.com>.
Thank you for your response, I', trying and all is ok. 
So include libraries in <script></script> isn't recomendend 

Thanks
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-1-0-5-repit-the-scripts-tp3261634p3262547.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: Tapestry 5.1.0.5 repit the scripts

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
As Howard said, Tapestry doesn't parse your .tml to avoid including  
JavaScript files twice. Instead of using <script> in your template, use  
the @IncludeJavaScriptLibrary annotation and the repetition won't happen  
again.

On Fri, 12 Nov 2010 16:16:38 -0200, iberck <ib...@gmail.com> wrote:

> Yes, I'm using the tapestry capabilities,the only diference is I'm using
> "${asset:context:js/jquery-1.4.2.min.js}" in the layout and
> @IncludeJavaScriptLibrary("context:js/jquery-1.4.2.min.js") in the mixin,
> this is my code:
>
> Layout.tml:
> ------------------------------------------------------
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
>       xmlns:p="tapestry:parameter">
>     <head>
>         <meta http-equiv="content-type" content="text/html;  
> charset=UTF-8"/>
>         <script type="text/javascript"
> src="${asset:context:js/jquery-1.4.2.min.js}"></script>
>          ...
>     </head>
> ...
> </html>
> ------------------------------------------------------
>
>
> Mixin:
> ------------------------------------------------------
> @IncludeJavaScriptLibrary({
>     "context:js/jquery-1.4.2.min.js",
>     "context:js/jquery.maskedinput-1.2.2.min.js",
>     "InputMask.js"
> })
> public class InputMask {
>
>     @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
>     private String mask;
>     @InjectContainer
>     private TextField parent;
>     @Inject
>     private RenderSupport renderSupport;
>
>     @AfterRender
>     void afterRender() {
>         renderSupport.addInit("inputmask", parent.getClientId(), mask);
>     }
> }
> ------------------------------------------------------
>
>
> InputMask.js:
> ------------------------------------------------------
> Tapestry.Initializer.inputmask = function(elementId,mask) {
>     jQuery("#"+elementId).mask(mask);
> }
> ------------------------------------------------------
>
>
> This is the output html head copy from firebug:
> ------------------------------------------------------
> <head>
> 	<meta content="text/html; charset=UTF-8" http-equiv="content-type">
> 	<link type="text/css" rel="stylesheet"
> href="/tara-web/assets/ctx/5426f79eddb28fae/css/t5-components.css">
> 	<link type="text/css" rel="stylesheet"
> href="/tara-web/assets/classpath/5426f79eddb28fae/org/got5/tapestry5/jquery/themes/ui-lightness/jquery-ui-1.8.custom.css">
> 	<link type="text/css" rel="stylesheet"
> href="/tara-web/assets/ctx/5426f79eddb28fae/css/mensajes.css">
> 	<link href="/tara-web/assets/ctx/5426f79eddb28fae/layout/styles.css"
> type="text/css" rel="stylesheet">
> 	<link href="/tara-web/assets/ctx/5426f79eddb28fae/css/botones.css"
> type="text/css" rel="stylesheet">
> 	<script src="/tara-web/assets/scriptaculous/5.1.0.5/prototype.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/scriptaculous/5.1.0.5/scriptaculous.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/scriptaculous/5.1.0.5/effects.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/tapestry/5.1.0.5/tapestry.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/blackbird/5.1.0.5/blackbird.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/tapestry/5.1.0.5/tapestry-messages.js"
> type="text/javascript"></script>
> 	<script  
> src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
> type="text/javascript"></script>
> 	<script
> src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery.maskedinput-1.2.2.min.js"
> type="text/javascript"></script>
> 	<script src="/tara-web/assets/app/5426f79eddb28fae/mixins/InputMask.js"
> type="text/javascript"></script>
> 	<script  
> src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
> type="text/javascript"></script>
> </head>	
> ------------------------------------------------------
>
> As you can see the jquery library is 2 times:
> <script  
> src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
> type="text/javascript"></script>
> <script  
> src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
> type="text/javascript"></script>
>
> Thanks in advance
>


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
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: Tapestry 5.1.0.5 repit the scripts

Posted by iberck <ib...@gmail.com>.
Thank you for time and your responses


Yes, I'm using the tapestry capabilities,the only diference is I'm using
"${asset:context:js/jquery-1.4.2.min.js}" in the layout and
@IncludeJavaScriptLibrary("context:js/jquery-1.4.2.min.js") in the mixin,
this is my code:

Layout.tml:
------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
      xmlns:p="tapestry:parameter">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript"
src="${asset:context:js/jquery-1.4.2.min.js}"></script>
         ...
    </head>
...
</html>
------------------------------------------------------


Mixin:
------------------------------------------------------
@IncludeJavaScriptLibrary({
    "context:js/jquery-1.4.2.min.js",
    "context:js/jquery.maskedinput-1.2.2.min.js",
    "InputMask.js"
})
public class InputMask {

    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String mask;
    @InjectContainer
    private TextField parent;
    @Inject
    private RenderSupport renderSupport;

    @AfterRender
    void afterRender() {
        renderSupport.addInit("inputmask", parent.getClientId(), mask);
    }
}
------------------------------------------------------


InputMask.js:
------------------------------------------------------
Tapestry.Initializer.inputmask = function(elementId,mask) {
    jQuery("#"+elementId).mask(mask);
}
------------------------------------------------------


This is the output html head copy from firebug:
------------------------------------------------------
<head>
	<meta content="text/html; charset=UTF-8" http-equiv="content-type">
	<link type="text/css" rel="stylesheet"
href="/tara-web/assets/ctx/5426f79eddb28fae/css/t5-components.css">
	<link type="text/css" rel="stylesheet"
href="/tara-web/assets/classpath/5426f79eddb28fae/org/got5/tapestry5/jquery/themes/ui-lightness/jquery-ui-1.8.custom.css">
	<link type="text/css" rel="stylesheet"
href="/tara-web/assets/ctx/5426f79eddb28fae/css/mensajes.css">
	<link href="/tara-web/assets/ctx/5426f79eddb28fae/layout/styles.css"
type="text/css" rel="stylesheet">
	<link href="/tara-web/assets/ctx/5426f79eddb28fae/css/botones.css"
type="text/css" rel="stylesheet">
	<script src="/tara-web/assets/scriptaculous/5.1.0.5/prototype.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/scriptaculous/5.1.0.5/scriptaculous.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/scriptaculous/5.1.0.5/effects.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/tapestry/5.1.0.5/tapestry.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/blackbird/5.1.0.5/blackbird.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/tapestry/5.1.0.5/tapestry-messages.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
type="text/javascript"></script>
	<script
src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery.maskedinput-1.2.2.min.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/app/5426f79eddb28fae/mixins/InputMask.js"
type="text/javascript"></script>
	<script src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
type="text/javascript"></script>
</head>	
------------------------------------------------------

As you can see the jquery library is 2 times:
<script src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
type="text/javascript"></script>
<script src="/tara-web/assets/ctx/5426f79eddb28fae/js/jquery-1.4.2.min.js"
type="text/javascript"></script>

Thanks in advance

-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-1-0-5-repit-the-scripts-tp3261634p3262533.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: Tapestry 5.1.0.5 repit the scripts

Posted by Howard Lewis Ship <hl...@gmail.com>.
Just make sure you use Tapestry's support for JavaScript libraries
(@IncludeJavaScriptLibrary in 5.1, or @Import in 5.2).

Tapestry DOES NOT parse the rendered HTML to look for libraries that you've
directly included in your template.  It relies on you being consistent about
using its built in capabilities (via the annotations, or direct calls into
RenderSupport (5.1) or JavaScriptSupport (5.2)).

There are significant other benefits to using the Tapestry mechanisms as
well.

On Fri, Nov 12, 2010 at 6:11 AM, Kado <ju...@condortech.com.ar> wrote:

> About this question.
>
> Here we are using a layout that includes different components.
> When we include jQuery lib in the mixins the jQuery doesn't works. We have
> to include the jQuery lib in the layout to make the mixins work.
>
> This is because we are not including pages and we are using components?
>
> Regards.
>
>
>
>
> On 11/12/2010 09:45 AM, Thiago H. de Paula Figueiredo wrote:
>
>> On Fri, 12 Nov 2010 07:04:51 -0200, iberck <ib...@gmail.com> wrote:
>>
>>  Pd. If I add the script 2 times my mixin breaks
>>>
>>
>> Are you including them though @IncludeJavascriptLibrary and using the same
>> expression to refer to the same file? If not, you should.
>>
>>
> ---------------------------------------------------------------------
> 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

Re: Tapestry 5.1.0.5 repit the scripts

Posted by Kado <ju...@condortech.com.ar>.
About this question.

Here we are using a layout that includes different components.
When we include jQuery lib in the mixins the jQuery doesn't works. We 
have to include the jQuery lib in the layout to make the mixins work.

This is because we are not including pages and we are using components?

Regards.



On 11/12/2010 09:45 AM, Thiago H. de Paula Figueiredo wrote:
> On Fri, 12 Nov 2010 07:04:51 -0200, iberck <ib...@gmail.com> wrote:
>
>> Pd. If I add the script 2 times my mixin breaks
>
> Are you including them though @IncludeJavascriptLibrary and using the 
> same expression to refer to the same file? If not, you should.
>

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


Re: Tapestry 5.1.0.5 repit the scripts

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 12 Nov 2010 07:04:51 -0200, iberck <ib...@gmail.com> wrote:

> Pd. If I add the script 2 times my mixin breaks

Are you including them though @IncludeJavascriptLibrary and using the same  
expression to refer to the same file? If not, you should.

-- 
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: Tapestry 5.1.0.5 repit the scripts

Posted by iberck <ib...@gmail.com>.
Pd. If I add the script 2 times my mixin breaks

Thanks in advance for your responses

-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-1-0-5-repit-the-scripts-tp3261634p3261657.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