Hi Thiago > The component being inside a block (you mean <t:block>?) shouldn't make a > difference. How are you rendering this block?
Yeap, to simplify the problem, the tapestry5-jquery's GMap component has the same problem, with the next code the component renders correctly the google map. Test.tml <div t:type="jquery/gmap" t:id="map" t:parameters="options"></div> Test.java public class Test { public JSONObject getOptions(){ JSONObject json = new JSONObject(); return json; } } With the next code the GMap component does not render correctly the map after you click the refresh link (to show the block). Test2.tml: <t:actionlink t:id="refresh" zone='zoneResults'>refresh</t:actionlink> <t:zone id='zoneResults'/> <t:block t:id="blockResults"> <div t:type="jquery/gmap" t:id="map" t:parameters="options"></div> </t:block> Test2.java: public class Test2 { @Inject private Block blockResults; Object onActionFromRefresh() { return blockResults; } public JSONObject getOptions(){ JSONObject json = new JSONObject(); return json; } } When you press refresh link the browser (Chrome) javascript console error is: "Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened." Reference: tapestry5-jquery's GMap component source code: https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/components/GMap.java tapestry5-jquery's GMap component example: http://tapestry5 jquery.com/components/docsgmap;jsessionid=A5260C324E4C8E97299C0E556621697D.FA4B475DA717# Thanks in advance -----Mensaje original----- De: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] Enviado el: viernes, 26 de septiembre de 2014 08:20 a.m. Para: Tapestry users Asunto: Re: [T5] How can I validate if a script is present ? On Fri, 26 Sep 2014 01:09:14 -0300, Carlos Gómez Montiel <ibe...@gmail.com> wrote: > Hi Thiago, thank you for your answer :) I'm using Tapestry 5.3.7 Hi! > Testing it, I have created a file (googlemaps.js) with the content of > the url: "https://maps.googleapis.com/maps/api/js?v=3.exp" and > included it inside component: > @Import(library = > "classpath:mx/kka/msurvey/web/view/components/maps/googlemaps.js") > public class GMapShow { > } This way (which I suggested, I'm sorry), with the external library included in setupRender() and your code that uses it included via @Import, the two JS files are included in the wrong order, because @Import is processed before setupRender(). Please try this: @Inject @Path("classpath:mx/kka/msurvey/web/view/components/maps/googlemaps.js") private Asset myCode; public void setupRender() { javaScriptSupport.importJavaScriptLibrary("https://maps.googleapis.com/maps/api/js?v=3.exp"); javaScriptSupport.importJavaScriptLibrary(myCode); ) This will guarantee your code will be included after the Google Maps API. > But the result is the same, the map is rendered correctly if the > component is outside a block but if the component is inside a block, > the map is not renderer. The component being inside a block (you mean <t:block>?) shouldn't make a difference. How are you rendering this block? >> That's why we ask people more information and snippets of code when >> asking help: the original question in the subject of the message (how >> can I validate if a script is present), which, by the way, is >> JavaScript-specific, not Tapestry-specific, wouldn't need to be asked. > > Ok Thiago, thank you for your feedback. > I think the question is about tapestry because I need to validate > inside a tapestry's component if its parent page contains the string > <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"> ;) You don't need this, but, if you really needed it, you could rename your setupRender() method to beginRender(MarkupWriter writer) and writer.getDocument() provides you the Tapestry DOM of the page rendered so far. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org