You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by raulmt <ra...@gmail.com> on 2009/11/23 22:13:09 UTC

Combining Javascript doesn't work with libraries like TinyMCE

Hello,

Combining Javascripts feature in T5.1 is great, but sadly I had to disable
it. I use TinyMCE and this library uses its own path (where tiny_mce.js
"lives") to load other files that are needed (themes, languages, etc.). The
problem arises when tiny_mce.js is in the combined virtual asset because it
doesn't find any script tag with itself as the src so TinyMCE can't figure
out the path to load the other assets.

I think there should be a way to specify that some scripts should not be
combined because sometimes (like in this case) is a must have... "all or
nothing" isn't optimal. I looked into the Tapestry code and doesn't seem to
be possible currently... is there a way? should I post a ticket in jira
about per-script combining configuration?

Regards.
-- 
View this message in context: http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054005.html
Sent from the Tapestry Users 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 25 Nov 2009 19:21:07 -0200, Howard Lewis Ship <hl...@gmail.com>  
escreveu:

> I'm afraid its time to go for something a bit more structured:
>
> @ImportJavaScript({
>   @Import("classpath:foo.js" filter="IE5" combine=false),
>   @Import("context:bar.js")})
> public class MyJSComponent ...

Looks good to me. I just suggest not using just @Import, as it would be  
confusing for eventual other types of import.

What about

@ImportJavaScripts({
    @ImportJavaScript(value = "classpath:foo.js", filter="IE5",  
combine=false),
    @ImportJavaScript("context:bar.js")})
public class MyJSComponent ...

It uses a similar convention naming used in the JPA annotations  
(@SecondaryTables, @SecondaryTable)

> This raises some ambiguities: what if different imports of the same JS
> file use different values for filter or combine?  I'd say that's an
> error.

+1 for error.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by Ulrich Stärk <ul...@spielviel.de>.
What exactly do you have in mind with the filter attribute? Because I 
could think of situations where you might want to import the same file 
for different browser versions.

Uli

Howard Lewis Ship schrieb:
> I'm afraid its time to go for something a bit more structured:
> 
> @ImportJavaScript({
>   @Import("classpath:foo.js" filter="IE5" combine=false),
>   @Import("context:bar.js")})
> public class MyJSComponent ...
> 
> 
> ... also the term "import" is much more accurate than "include".
> 
> This raises some ambiguities: what if different imports of the same JS
> file use different values for filter or combine?  I'd say that's an
> error.
> 
> 
> On Tue, Nov 24, 2009 at 12:38 PM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
>> Em Tue, 24 Nov 2009 18:25:10 -0200, Howard Lewis Ship <hl...@gmail.com>
>> escreveu:
>>
>>> I'm picturing this as a new form of the @IncludeJavascript annotation
>>> that allows new options to be included, such as browser type (i.e.,
>>> build that comment thingey around the <script> tag) and combine=false.
>> Would it be a new annotation or just adding properties to
>> @IncludeJavascript?
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
>> instructor
>> Owner, software architect and developer, 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
>>
>>
> 
> 
> 


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


Re: Combining Javascript doesn't work with libraries like TinyMCE

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'm afraid its time to go for something a bit more structured:

@ImportJavaScript({
  @Import("classpath:foo.js" filter="IE5" combine=false),
  @Import("context:bar.js")})
public class MyJSComponent ...


... also the term "import" is much more accurate than "include".

This raises some ambiguities: what if different imports of the same JS
file use different values for filter or combine?  I'd say that's an
error.


On Tue, Nov 24, 2009 at 12:38 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Tue, 24 Nov 2009 18:25:10 -0200, Howard Lewis Ship <hl...@gmail.com>
> escreveu:
>
>> I'm picturing this as a new form of the @IncludeJavascript annotation
>> that allows new options to be included, such as browser type (i.e.,
>> build that comment thingey around the <script> tag) and combine=false.
>
> Would it be a new annotation or just adding properties to
> @IncludeJavascript?
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, software architect and developer, 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
>
>



-- 
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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 24 Nov 2009 18:25:10 -0200, Howard Lewis Ship <hl...@gmail.com>  
escreveu:

> I'm picturing this as a new form of the @IncludeJavascript annotation
> that allows new options to be included, such as browser type (i.e.,
> build that comment thingey around the <script> tag) and combine=false.

Would it be a new annotation or just adding properties to  
@IncludeJavascript?

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'm picturing this as a new form of the @IncludeJavascript annotation
that allows new options to be included, such as browser type (i.e.,
build that comment thingey around the <script> tag) and combine=false.

On Tue, Nov 24, 2009 at 12:02 PM, Josh Canfield <jo...@thedailytube.com> wrote:
>> However, I think the ticket should still be considered.
>
> Definitely.
>
> On Tue, Nov (i.e.24, 2009 at 7:07 AM, raulmt <ra...@gmail.com> wrote:
>>
>> This is a good workaround, thanks.
>>
>> This won't work when the textarea with TinyMCE is loaded from an Ajax
>> request, though. Nevertheless, the problem shouldn't arise when the script
>> is loaded from an Ajax request, so in case the request is an Ajax request,
>> you can include it with RenderSupport as usual and if it is not, then use
>> the form you just described. Thanks, Josh, that should do the trick.
>>
>> However, I think the ticket should still be considered. Including a script
>> that doens't work when combined with others is not a very "rare case", so
>> built-in support without recurring to workarounds would be really helpful.
>>
>> Regards.
>>
>>
>> Josh Canfield wrote:
>>>
>>> Here is a workaround that I used in my tinymce mixin.
>>>
>>> void afterRender(MarkupWriter writer) {
>>>         // inject script in a non-combinable way
>>>         final String scriptelementid = "tinymce-script";
>>>         final Element src =
>>> writer.getDocument().getElementById(scriptelementid);
>>>         if (src == null) {
>>>             final String path =
>>> _symbolSource.valueForSymbol("tinymce") + "/tiny_mce.js";
>>>             final Asset asset =
>>> _assetSource.getAsset(_resources.getBaseResource(), path,
>>> _resources.getLocale());
>>>             Element dest = writer.getDocument().find("html/head");
>>>             if (dest != null) {
>>>                 dest.element("script", "src", asset.toClientURL(),
>>> "id", scriptelementid);
>>>             }
>>>         }
>>> }
>>>
>>> Josh
>>>
>>> On Mon, Nov 23, 2009 at 1:13 PM, raulmt <ra...@gmail.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> Combining Javascripts feature in T5.1 is great, but sadly I had to
>>>> disable
>>>> it. I use TinyMCE and this library uses its own path (where tiny_mce.js
>>>> "lives") to load other files that are needed (themes, languages, etc.).
>>>> The
>>>> problem arises when tiny_mce.js is in the combined virtual asset because
>>>> it
>>>> doesn't find any script tag with itself as the src so TinyMCE can't
>>>> figure
>>>> out the path to load the other assets.
>>>>
>>>> I think there should be a way to specify that some scripts should not be
>>>> combined because sometimes (like in this case) is a must have... "all or
>>>> nothing" isn't optimal. I looked into the Tapestry code and doesn't seem
>>>> to
>>>> be possible currently... is there a way? should I post a ticket in jira
>>>> about per-script combining configuration?
>>>>
>>>> Regards.
>>>> --
>>>> View this message in context:
>>>> http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054005.html
>>>> Sent from the Tapestry Users 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
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> --
>>> TheDailyTube.com. Sign up and get the best new videos on the internet
>>> delivered fresh to your inbox.
>>>
>>> ---------------------------------------------------------------------
>>> 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://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4058340.html
>> Sent from the Tapestry Users 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
>>
>>
>
>
>
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
> ---------------------------------------------------------------------
> 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by Josh Canfield <jo...@thedailytube.com>.
> However, I think the ticket should still be considered.

Definitely.

On Tue, Nov 24, 2009 at 7:07 AM, raulmt <ra...@gmail.com> wrote:
>
> This is a good workaround, thanks.
>
> This won't work when the textarea with TinyMCE is loaded from an Ajax
> request, though. Nevertheless, the problem shouldn't arise when the script
> is loaded from an Ajax request, so in case the request is an Ajax request,
> you can include it with RenderSupport as usual and if it is not, then use
> the form you just described. Thanks, Josh, that should do the trick.
>
> However, I think the ticket should still be considered. Including a script
> that doens't work when combined with others is not a very "rare case", so
> built-in support without recurring to workarounds would be really helpful.
>
> Regards.
>
>
> Josh Canfield wrote:
>>
>> Here is a workaround that I used in my tinymce mixin.
>>
>> void afterRender(MarkupWriter writer) {
>>         // inject script in a non-combinable way
>>         final String scriptelementid = "tinymce-script";
>>         final Element src =
>> writer.getDocument().getElementById(scriptelementid);
>>         if (src == null) {
>>             final String path =
>> _symbolSource.valueForSymbol("tinymce") + "/tiny_mce.js";
>>             final Asset asset =
>> _assetSource.getAsset(_resources.getBaseResource(), path,
>> _resources.getLocale());
>>             Element dest = writer.getDocument().find("html/head");
>>             if (dest != null) {
>>                 dest.element("script", "src", asset.toClientURL(),
>> "id", scriptelementid);
>>             }
>>         }
>> }
>>
>> Josh
>>
>> On Mon, Nov 23, 2009 at 1:13 PM, raulmt <ra...@gmail.com> wrote:
>>>
>>> Hello,
>>>
>>> Combining Javascripts feature in T5.1 is great, but sadly I had to
>>> disable
>>> it. I use TinyMCE and this library uses its own path (where tiny_mce.js
>>> "lives") to load other files that are needed (themes, languages, etc.).
>>> The
>>> problem arises when tiny_mce.js is in the combined virtual asset because
>>> it
>>> doesn't find any script tag with itself as the src so TinyMCE can't
>>> figure
>>> out the path to load the other assets.
>>>
>>> I think there should be a way to specify that some scripts should not be
>>> combined because sometimes (like in this case) is a must have... "all or
>>> nothing" isn't optimal. I looked into the Tapestry code and doesn't seem
>>> to
>>> be possible currently... is there a way? should I post a ticket in jira
>>> about per-script combining configuration?
>>>
>>> Regards.
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054005.html
>>> Sent from the Tapestry Users 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
>>>
>>>
>>
>>
>>
>> --
>> --
>> TheDailyTube.com. Sign up and get the best new videos on the internet
>> delivered fresh to your inbox.
>>
>> ---------------------------------------------------------------------
>> 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://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4058340.html
> Sent from the Tapestry Users 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
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: Combining Javascript doesn't work with libraries like TinyMCE

Posted by raulmt <ra...@gmail.com>.
This is a good workaround, thanks.

This won't work when the textarea with TinyMCE is loaded from an Ajax
request, though. Nevertheless, the problem shouldn't arise when the script
is loaded from an Ajax request, so in case the request is an Ajax request,
you can include it with RenderSupport as usual and if it is not, then use
the form you just described. Thanks, Josh, that should do the trick.

However, I think the ticket should still be considered. Including a script
that doens't work when combined with others is not a very "rare case", so
built-in support without recurring to workarounds would be really helpful.

Regards.


Josh Canfield wrote:
> 
> Here is a workaround that I used in my tinymce mixin.
> 
> void afterRender(MarkupWriter writer) {
>         // inject script in a non-combinable way
>         final String scriptelementid = "tinymce-script";
>         final Element src =
> writer.getDocument().getElementById(scriptelementid);
>         if (src == null) {
>             final String path =
> _symbolSource.valueForSymbol("tinymce") + "/tiny_mce.js";
>             final Asset asset =
> _assetSource.getAsset(_resources.getBaseResource(), path,
> _resources.getLocale());
>             Element dest = writer.getDocument().find("html/head");
>             if (dest != null) {
>                 dest.element("script", "src", asset.toClientURL(),
> "id", scriptelementid);
>             }
>         }
> }
> 
> Josh
> 
> On Mon, Nov 23, 2009 at 1:13 PM, raulmt <ra...@gmail.com> wrote:
>>
>> Hello,
>>
>> Combining Javascripts feature in T5.1 is great, but sadly I had to
>> disable
>> it. I use TinyMCE and this library uses its own path (where tiny_mce.js
>> "lives") to load other files that are needed (themes, languages, etc.).
>> The
>> problem arises when tiny_mce.js is in the combined virtual asset because
>> it
>> doesn't find any script tag with itself as the src so TinyMCE can't
>> figure
>> out the path to load the other assets.
>>
>> I think there should be a way to specify that some scripts should not be
>> combined because sometimes (like in this case) is a must have... "all or
>> nothing" isn't optimal. I looked into the Tapestry code and doesn't seem
>> to
>> be possible currently... is there a way? should I post a ticket in jira
>> about per-script combining configuration?
>>
>> Regards.
>> --
>> View this message in context:
>> http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054005.html
>> Sent from the Tapestry Users 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
>>
>>
> 
> 
> 
> -- 
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
> 
> ---------------------------------------------------------------------
> 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://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4058340.html
Sent from the Tapestry Users 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by Josh Canfield <jo...@thedailytube.com>.
Here is a workaround that I used in my tinymce mixin.

void afterRender(MarkupWriter writer) {
        // inject script in a non-combinable way
        final String scriptelementid = "tinymce-script";
        final Element src =
writer.getDocument().getElementById(scriptelementid);
        if (src == null) {
            final String path =
_symbolSource.valueForSymbol("tinymce") + "/tiny_mce.js";
            final Asset asset =
_assetSource.getAsset(_resources.getBaseResource(), path,
_resources.getLocale());
            Element dest = writer.getDocument().find("html/head");
            if (dest != null) {
                dest.element("script", "src", asset.toClientURL(),
"id", scriptelementid);
            }
        }
}

Josh

On Mon, Nov 23, 2009 at 1:13 PM, raulmt <ra...@gmail.com> wrote:
>
> Hello,
>
> Combining Javascripts feature in T5.1 is great, but sadly I had to disable
> it. I use TinyMCE and this library uses its own path (where tiny_mce.js
> "lives") to load other files that are needed (themes, languages, etc.). The
> problem arises when tiny_mce.js is in the combined virtual asset because it
> doesn't find any script tag with itself as the src so TinyMCE can't figure
> out the path to load the other assets.
>
> I think there should be a way to specify that some scripts should not be
> combined because sometimes (like in this case) is a must have... "all or
> nothing" isn't optimal. I looked into the Tapestry code and doesn't seem to
> be possible currently... is there a way? should I post a ticket in jira
> about per-script combining configuration?
>
> Regards.
> --
> View this message in context: http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054005.html
> Sent from the Tapestry Users 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
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: Combining Javascript doesn't work with libraries like TinyMCE

Posted by raulmt <ra...@gmail.com>.
https://issues.apache.org/jira/browse/TAP5-935

If you have something to add or clarify, please do it as well ;)


Thiago H. de Paula Figueiredo wrote:
> 
> Em Mon, 23 Nov 2009 19:13:09 -0200, raulmt <ra...@gmail.com> escreveu:
> 
>> Hello,
> 
> Hi!
> 
>> should I post a ticket in jira about per-script combining configuration?
> 
> Please do it.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, software architect and developer, 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
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Combining-Javascript-doesn-t-work-with-libraries-like-TinyMCE-tp4054005p4054444.html
Sent from the Tapestry Users 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: Combining Javascript doesn't work with libraries like TinyMCE

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 23 Nov 2009 19:13:09 -0200, raulmt <ra...@gmail.com> escreveu:

> Hello,

Hi!

> should I post a ticket in jira about per-script combining configuration?

Please do it.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, 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