You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jochen Berger <fo...@googlemail.com> on 2012/03/05 09:29:00 UTC
Scripts can be added to markup multiple times via different stacks
Hi,
I just observed that if I add a JS library to two different stacks and
import them in a page, that asset is added to the page twice.
This happens because JavaScriptSupportImpl does check for duplicate
stylesheets (L 327) and stacks (L 294) but not for duplicate scripts. Is
that expected or should I add a JIRA/patch?
Regards,
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Scripts can be added to markup multiple times via different stacks
Posted by Jochen Berger <fo...@googlemail.com>.
Hi,
Am 06.03.2012 10:48, schrieb Lance Java:
> For the record, I don't think that it's an error to have two stacks sharing
> the same artifact in your application.
>
> I think the error exists when a page is attempting to import two stacks
> which share the same artifact.
Correct, but that can only be checked upon the page's construction, not
upon the JavaScriptStackSource's initialization. But maybe that's a
better approach anyway as it would line up nicely with the component id
validation that was added in 5.3.
However, it's only a matter of where the "error" is detected anyway. So
I'd say JavaScriptSupportImpl.addAssetsFromStack(String) would be the
best place to do it, just in case I should get bored and write a patch. ;-)
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Scripts can be added to markup multiple times via different stacks
Posted by Lance Java <la...@googlemail.com>.
For the record, I don't think that it's an error to have two stacks sharing
the same artifact in your application.
I think the error exists when a page is attempting to import two stacks
which share the same artifact.
On Tuesday, 6 March 2012, Lance Java <la...@googlemail.com> wrote:
> I agree that tapestry could be nice and at the least should log a warning
to the console in this case.
>
> As you said, throwing an exception would be good too... at least in
development mode. Not sure but perhaps it should throw exceptions if some
(configurable) symbol is set to "true".
>
> I think this is worthy of a Jira issue.
>
> On Tuesday, 6 March 2012, Jochen Berger <fo...@googlemail.com> wrote:
>> Hi,
>>
>> Am 05.03.2012 11:41, schrieb Lance Java:
>>>
>>> The javascript stack concept exists so that the stack remains constant
and
>>> can be cached by the client's browser.
>>>
>>> You are now asking to break this contract and have stacks be dynamic
based
>>> on what components are on a page which would eliminate the ability to
cache
>>> them in the client's browser.
>>
>> Right, I missed that ignoring duplicates would break the stack
assembling feature. But I still see problems with the current behavior. I
think we should find a way to prevent someone from creating stack setups
like mine (a single asset being used in multiple stacks). Maybe
JavaScriptStackSource(Impl) could log a warning or even throw an exception
if that is done. What do you think?
>>
>> Jochen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
Re: Scripts can be added to markup multiple times via different stacks
Posted by Lance Java <la...@googlemail.com>.
I agree that tapestry could be nice and at the least should log a warning
to the console in this case.
As you said, throwing an exception would be good too... at least in
development mode. Not sure but perhaps it should throw exceptions if some
(configurable) symbol is set to "true".
I think this is worthy of a Jira issue.
On Tuesday, 6 March 2012, Jochen Berger <fo...@googlemail.com> wrote:
> Hi,
>
> Am 05.03.2012 11:41, schrieb Lance Java:
>>
>> The javascript stack concept exists so that the stack remains constant
and
>> can be cached by the client's browser.
>>
>> You are now asking to break this contract and have stacks be dynamic
based
>> on what components are on a page which would eliminate the ability to
cache
>> them in the client's browser.
>
> Right, I missed that ignoring duplicates would break the stack assembling
feature. But I still see problems with the current behavior. I think we
should find a way to prevent someone from creating stack setups like mine
(a single asset being used in multiple stacks). Maybe
JavaScriptStackSource(Impl) could log a warning or even throw an exception
if that is done. What do you think?
>
> Jochen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Scripts can be added to markup multiple times via different stacks
Posted by Jochen Berger <fo...@googlemail.com>.
Hi,
Am 05.03.2012 11:41, schrieb Lance Java:
> The javascript stack concept exists so that the stack remains constant and
> can be cached by the client's browser.
>
> You are now asking to break this contract and have stacks be dynamic based
> on what components are on a page which would eliminate the ability to cache
> them in the client's browser.
Right, I missed that ignoring duplicates would break the stack
assembling feature. But I still see problems with the current behavior.
I think we should find a way to prevent someone from creating stack
setups like mine (a single asset being used in multiple stacks). Maybe
JavaScriptStackSource(Impl) could log a warning or even throw an
exception if that is done. What do you think?
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Scripts can be added to markup multiple times via different stacks
Posted by Lance Java <la...@googlemail.com>.
The javascript stack concept exists so that the stack remains constant and
can be cached by the client's browser.
You are now asking to break this contract and have stacks be dynamic based
on what components are on a page which would eliminate the ability to cache
them in the client's browser.
I suggest that you re-think your javascript stacks so that you bunch things
together that really belong together.
Cheers,
Lance.
On Monday, 5 March 2012, Jochen Berger <fo...@googlemail.com> wrote:
> Hi,
>
> I just observed that if I add a JS library to two different stacks and
import them in a page, that asset is added to the page twice.
> This happens because JavaScriptSupportImpl does check for duplicate
stylesheets (L 327) and stacks (L 294) but not for duplicate scripts. Is
that expected or should I add a JIRA/patch?
>
> Regards,
> Jochen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>