You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sommeralex <al...@gmail.com> on 2012/09/15 19:12:45 UTC

loading .js and in a specific order

Hi!

I need to ensure that google maps api 3 is loaded before 
OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
helping to solve the multiple marker problem with same locations)

The  OverlappingMarkerSpiderfier.js is in my ressources folder, and normally
i would just inject it via @Import(library =
{"context:js/OverlappingMarkerSpiderfier.js",})

the point is, that the overlapping marker is always loaded then BEFORE
google maps api loaded. how can i change the order, that
OverlappingMarkerSpiderfier.js is loaded after google maps, which is loaded
via the script tag:



thx



--
View this message in context: http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.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: loading .js and in a specific order

Posted by Dusko Jovanovski <du...@gmail.com>.
That shouldn't be a problem, you can access that parameter
within AssetPathConverter (I'm assuming you are using a constant or a
symbol for the googleMapsKey). It might seem complicated, but in the long
run it should be worth it, since this override provides a way to import
libraries from CDN.

On Sat, Sep 15, 2012 at 10:25 PM, sommeralex <al...@gmail.com>wrote:

> thx.. but seems complicated, because my asset also is taking parameters:
>
>
> <script type="text/javascript" src="
>
> http://maps.googleapis.com/maps/api/js?libraries=geometry&amp;key=${googleMapsKey}&amp;sensor=false
> ">
>
> 2012/9/15 Dusko Jovanovski [via Tapestry] <
> ml-node+s1045711n5716314h76@n5.nabble.com>
>
> > Just read your question again (on nabble, the script tag was lost in the
> > email), and I realized that's not gonna help.
> > Take a look at this thread:
> >
> >
> http://tapestry.1045711.n5.nabble.com/Referencing-external-assets-td4346215.html
> >
> >
> > Basically, you need to override AssetPathConverter, and then use @Import
> > for the google maps library instead of the import via script.
> >
> > On Sat, Sep 15, 2012 at 10:05 PM, Dusko Jovanovski <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716314&i=0>>wrote:
> >
> >
> > > You can use the @Import annotation on render methods. Try this:
> > > @Import(library = {"context:js/OverlappingMarkerSpiderfier.js"})
> > > void afterRender(){}
> > >
> > >
> > > On Sat, Sep 15, 2012 at 7:12 PM, sommeralex <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716314&i=1>>wrote:
> >
> > >
> > >> Hi!
> > >>
> > >> I need to ensure that google maps api 3 is loaded before
> > >> OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
> > >> helping to solve the multiple marker problem with same locations)
> > >>
> > >> The  OverlappingMarkerSpiderfier.js is in my ressources folder, and
> > >> normally
> > >> i would just inject it via @Import(library =
> > >> {"context:js/OverlappingMarkerSpiderfier.js",})
> > >>
> > >> the point is, that the overlapping marker is always loaded then BEFORE
> > >> google maps api loaded. how can i change the order, that
> > >> OverlappingMarkerSpiderfier.js is loaded after google maps, which is
> > >> loaded
> > >> via the script tag:
> > >>
> > >>
> > >>
> > >> thx
> > >>
> > >>
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.html
> > >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716314&i=2>
> > >> For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5716314&i=3>
> > >>
> > >>
> > >
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716314.html
> >  To unsubscribe from loading .js and <scripts> in a specific order, click
> > here<
> http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716309&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjMwOXwxMDUzMzQxMzM4
> >
> > .
> > NAML<
> http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716315.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>

Re: loading .js and in a specific order

Posted by sommeralex <al...@gmail.com>.
thx.. but seems complicated, because my asset also is taking parameters:


<script type="text/javascript" src="
http://maps.googleapis.com/maps/api/js?libraries=geometry&amp;key=${googleMapsKey}&amp;sensor=false
">

2012/9/15 Dusko Jovanovski [via Tapestry] <
ml-node+s1045711n5716314h76@n5.nabble.com>

> Just read your question again (on nabble, the script tag was lost in the
> email), and I realized that's not gonna help.
> Take a look at this thread:
>
> http://tapestry.1045711.n5.nabble.com/Referencing-external-assets-td4346215.html
>
>
> Basically, you need to override AssetPathConverter, and then use @Import
> for the google maps library instead of the import via script.
>
> On Sat, Sep 15, 2012 at 10:05 PM, Dusko Jovanovski <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716314&i=0>>wrote:
>
>
> > You can use the @Import annotation on render methods. Try this:
> > @Import(library = {"context:js/OverlappingMarkerSpiderfier.js"})
> > void afterRender(){}
> >
> >
> > On Sat, Sep 15, 2012 at 7:12 PM, sommeralex <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716314&i=1>>wrote:
>
> >
> >> Hi!
> >>
> >> I need to ensure that google maps api 3 is loaded before
> >> OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
> >> helping to solve the multiple marker problem with same locations)
> >>
> >> The  OverlappingMarkerSpiderfier.js is in my ressources folder, and
> >> normally
> >> i would just inject it via @Import(library =
> >> {"context:js/OverlappingMarkerSpiderfier.js",})
> >>
> >> the point is, that the overlapping marker is always loaded then BEFORE
> >> google maps api loaded. how can i change the order, that
> >> OverlappingMarkerSpiderfier.js is loaded after google maps, which is
> >> loaded
> >> via the script tag:
> >>
> >>
> >>
> >> thx
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716314&i=2>
> >> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716314&i=3>
> >>
> >>
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716314.html
>  To unsubscribe from loading .js and <scripts> in a specific order, click
> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716309&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjMwOXwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716315.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: loading .js and in a specific order

Posted by Dusko Jovanovski <du...@gmail.com>.
Just read your question again (on nabble, the script tag was lost in the
email), and I realized that's not gonna help.
Take a look at this thread:
http://tapestry.1045711.n5.nabble.com/Referencing-external-assets-td4346215.html


Basically, you need to override AssetPathConverter, and then use @Import
for the google maps library instead of the import via script.

On Sat, Sep 15, 2012 at 10:05 PM, Dusko Jovanovski <du...@gmail.com>wrote:

> You can use the @Import annotation on render methods. Try this:
> @Import(library = {"context:js/OverlappingMarkerSpiderfier.js"})
> void afterRender(){}
>
>
> On Sat, Sep 15, 2012 at 7:12 PM, sommeralex <al...@gmail.com>wrote:
>
>> Hi!
>>
>> I need to ensure that google maps api 3 is loaded before
>> OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
>> helping to solve the multiple marker problem with same locations)
>>
>> The  OverlappingMarkerSpiderfier.js is in my ressources folder, and
>> normally
>> i would just inject it via @Import(library =
>> {"context:js/OverlappingMarkerSpiderfier.js",})
>>
>> the point is, that the overlapping marker is always loaded then BEFORE
>> google maps api loaded. how can i change the order, that
>> OverlappingMarkerSpiderfier.js is loaded after google maps, which is
>> loaded
>> via the script tag:
>>
>>
>>
>> thx
>>
>>
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.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: loading .js and in a specific order

Posted by sommeralex <al...@gmail.com>.
tried this already

myPageClass:

@Import(library = {"context:/js/OverlappingMarkerSpiderfier.js"})

void afterRender(){

 }



myPageTML:


<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">



<t:googleMaps3 />


</t:layout>



myGoogleMaps3.tml:


<script type="text/javascript" src="
http://maps.googleapis.com/maps/api/js?libraries=geometry&amp;key=${googleMapsKey}&amp;sensor=false
">



 alert ('google maps');


</script>



OverlappingMarkerSpiderfier.js:


first line is alert('OverlappingMarkerSpiderfier');




alert OverlappingMarkerSpiderfier is before  alert ('google maps');




2012/9/15 Dusko Jovanovski [via Tapestry] <
ml-node+s1045711n5716312h14@n5.nabble.com>

> You can use the @Import annotation on render methods. Try this:
> @Import(library = {"context:js/OverlappingMarkerSpiderfier.js"})
> void afterRender(){}
>
> On Sat, Sep 15, 2012 at 7:12 PM, sommeralex <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716312&i=0>>wrote:
>
>
> > Hi!
> >
> > I need to ensure that google maps api 3 is loaded before
> > OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
> > helping to solve the multiple marker problem with same locations)
> >
> > The  OverlappingMarkerSpiderfier.js is in my ressources folder, and
> > normally
> > i would just inject it via @Import(library =
> > {"context:js/OverlappingMarkerSpiderfier.js",})
> >
> > the point is, that the overlapping marker is always loaded then BEFORE
> > google maps api loaded. how can i change the order, that
> > OverlappingMarkerSpiderfier.js is loaded after google maps, which is
> loaded
> > via the script tag:
> >
> >
> >
> > thx
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716312&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5716312&i=2>
> >
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716312.html
>  To unsubscribe from loading .js and <scripts> in a specific order, click
> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716309&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNjMwOXwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716313.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: loading .js and in a specific order

Posted by Dusko Jovanovski <du...@gmail.com>.
You can use the @Import annotation on render methods. Try this:
@Import(library = {"context:js/OverlappingMarkerSpiderfier.js"})
void afterRender(){}

On Sat, Sep 15, 2012 at 7:12 PM, sommeralex <al...@gmail.com>wrote:

> Hi!
>
> I need to ensure that google maps api 3 is loaded before
> OverlappingMarkerSpiderfier ( OverlappingMarkerSpiderfier is a js lib
> helping to solve the multiple marker problem with same locations)
>
> The  OverlappingMarkerSpiderfier.js is in my ressources folder, and
> normally
> i would just inject it via @Import(library =
> {"context:js/OverlappingMarkerSpiderfier.js",})
>
> the point is, that the overlapping marker is always loaded then BEFORE
> google maps api loaded. how can i change the order, that
> OverlappingMarkerSpiderfier.js is loaded after google maps, which is loaded
> via the script tag:
>
>
>
> thx
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309.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: loading .js and in a specific order

Posted by sommeralex <al...@gmail.com>.
thank you!!! is working.

package com.airwriting.frontend.components;

import org.apache.tapestry5.Asset;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

import com.airwriting.configuration.Configuration;

@Import(library = {"context:js/googlemaps3.js"})
public class GoogleMaps3 {
 @Inject
private Request request;

@Inject
private Configuration configuration;

@Property
private String googleMapsKey;
 @Inject
private JavaScriptSupport jsSupport;

@Inject
@Path("context:/js/omsmin.js")
private Asset asset;

void setupRender(MarkupWriter writer){
  //"
http://maps.googleapis.com/maps/api/js?libraries=geometry&amp;key=${googleMapsKey}&amp;sensor=false
"
 if (request.getServerName().endsWith(".net")){
googleMapsKey = configuration.getString("googleMaps.key.net");
}else if (request.getServerName().endsWith(".de")){
googleMapsKey = configuration.getString("googleMaps.key.de");
}else if (request.getServerName().endsWith(".at")){
googleMapsKey = configuration.getString("googleMaps.key.at");
}
else {//.com
googleMapsKey = configuration.getString("googleMaps.key");
}
 String src = "
http://maps.googleapis.com/maps/api/js?libraries=geometry&key="+
googleMapsKey + "&sensor=false";

writer.getDocument().getRootElement().find("head").elementAt(0, "script",
"type", "text/javascript", "src", asset.toString());
writer.getDocument().getRootElement().find("head").elementAt(0, "script",
"type", "text/javascript", "src", src);
 }

}




--
View this message in context: http://tapestry.1045711.n5.nabble.com/loading-js-and-scripts-in-a-specific-order-tp5716309p5716318.html
Sent from the Tapestry - User mailing list archive at Nabble.com.