Re: [T5] How can I validate if a script is present ?
On Fri, 26 Sep 2014 16:12:18 -0300, Carlos Gómez Montiel wrote: Thank you for your help and support Thiago, I prefer wait to T5.4 release ;) You can already try the 5.4-beta-24, which is very close to final. -- 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
RE: [T5] How can I validate if a script is present ?
Thank you for your help and support Thiago, I prefer wait to T5.4 release ;) Regards -Mensaje original- De: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] Enviado el: viernes, 26 de septiembre de 2014 01:23 p.m. Para: Tapestry users Asunto: Re: [T5] How can I validate if a script is present ? On Fri, 26 Sep 2014 14:04:01 -0300, Carlos Gómez Montiel wrote: > Hi Thiago Hi! > refresh > > > t:parameters="options"> > If you had mentioned before you were trying to show it in a Zone update, we would have understood the problem earlier. You can use blocks in non-AJAX scenarios too. In your case, using your own code, not the one from tapestry5-jquery, the check for whether the Google Maps is already loaded should be part of your own code. Not a good solution. Ultimately the solution is to use Require.js or a similar solution and let it handle the client-side dependencies and ensure the loading order of JavaScript files. Tapestry 5.4 supports it out-of-the-box. -- 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
Re: [T5] How can I validate if a script is present ?
On Fri, 26 Sep 2014 14:04:01 -0300, Carlos Gómez Montiel wrote: Hi Thiago Hi! refresh t:parameters="options"> If you had mentioned before you were trying to show it in a Zone update, we would have understood the problem earlier. You can use blocks in non-AJAX scenarios too. In your case, using your own code, not the one from tapestry5-jquery, the check for whether the Google Maps is already loaded should be part of your own code. Not a good solution. Ultimately the solution is to use Require.js or a similar solution and let it handle the client-side dependencies and ensure the loading order of JavaScript files. Tapestry 5.4 supports it out-of-the-box. -- 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
RE: [T5] How can I validate if a script is present ?
Hi Thiago > The component being inside a block (you mean ?) 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 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: refresh 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 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 ?) 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 >
Re: [T5] How can I validate if a script is present ?
On Fri, 26 Sep 2014 01:09:14 -0300, Carlos Gómez Montiel 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 ?) 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
RE: [T5] How can I validate if a script is present ?
Hi Lance, thank you for your answer. Yes, I have tried with exanpe library (versión 1.2.1) but it throws the javascript console error: Uncaught TypeError: Cannot set property 'ajaxValidator' of undefined exanpe-t5-lib.js:737 No Tapestry.Initializer function for : gMapBuilder: jQuery.fn.jQuery.init[0] Additionally I have tried with tapestry5-jquery's map component but the result is the same, the map is renderer ok if it is outside a block, if the component is inside a block the map is never renderer. Test2.tml: refrescar Test2.java: public class Test2 { public JSONObject getOptions() { JSONObject json = new JSONObject(); return json; } @Inject private Block blockResults; Object onActionFromRefrescar() { return blockResults; } } - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: [T5] How can I validate if a script is present ?
Hi Thiago, thank you for your answer :) I'm using Tapestry 5.3.7 > Where's your JavaScript? For google maps, you have to access the javascript library from a URL, so my javascript is inside the url: "https://maps.googleapis.com/maps/api/js?v=3.exp"; > How are you including it? public class GMapShow { @Inject private JavaScriptSupport javaScriptSupport; public void setupRender() { javaScriptSupport.importJavaScriptLibrary("https://maps.googleapis.com/maps/api/js?v=3.exp";); } } > If you put your JavaScript code inside a .js file and included using @Import > or JavaScriptSupport.importJavaScriptLibrary(), your code would be > automatically included after the library you're using. 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 { } 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. I suppose the javascript inside "https://maps.googleapis.com/maps/api/js?v=3.exp"; is loading another javascript files and maybe the component is rendered before all all javascript libraries are loaded. The javascript has snipets that looks like: getScript("https://maps.gstatic.com/maps-api-v3/api/js/18/5/intl/es_ALL/main.js";); apiLoad([0.00999776482582,[[["https://mts0.googleapis.com/vt?lyrs=m@27500\u0026src=api\u0026hl=es-ES\u0026","https://mts1.googleapis.com . > 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
RE: [T5] How can I validate if a script is present ?
Have you seen the exanpe gmap component? http://exanpe-t5-lib.appspot.com/components/googlemap/example2 On 25 Sep 2014 14:45, "Carlos Gómez Montiel" wrote: > Hi Thiago > Ok, I will more specific: > > I'm developing a Tapestry component (GMapShow) that renders a google map. > If I include the google maps javascript library directly in this component, > the map is not render if the component is inside a block, so I need to > include the library BEFORE the block (with the GMapShow component) is > rendered. > > So, I have created a component to only include the Google Maps library: > public class ImportGMapLib { > > @Inject > private JavaScriptSupport javaScriptSupport; > > public void beginRender() { > javaScriptSupport.importJavaScriptLibrary(" > https://maps.googleapis.com/maps/api/js?v=3.exp";); > } > } > > My "Test.tml" looks like this: > > > > refresh > > > > > > I need to validate from GMapEdit component if the javascript library " > https://maps.googleapis.com/maps/api/js?v=3.exp"; was imported, or > validate inside GMapEdit if the ImportGMapLib component was invoked inside > Test.tml. > > Thanks in advance. > > > -Mensaje original----- > De: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] > Enviado el: jueves, 25 de septiembre de 2014 07:29 a.m. > Para: Tapestry users > Asunto: Re: [T5] How can I validate if a script is present ? > > On Wed, 24 Sep 2014 21:59:44 -0300, Carlos Gómez Montiel > wrote: > > > Hi ¡ > > Hi! > > > How can I validate from a component if a script is inside tag > > of a container page? > > I'm sorry, but I have no idea which scenario are you trying to describe > here. Which validation is this? > > -- > 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 > >
Re: [T5] How can I validate if a script is present ?
On Thu, 25 Sep 2014 10:45:44 -0300, Carlos Gómez Montiel wrote: Hi Thiago Ok, I will more specific: Hi! Thanks for being more specific. :) We want to help, but it's quite hard I'm developing a Tapestry component (GMapShow) that renders a google map. If I include the google maps javascript library directly in this component, the map is not render if the component is inside a block, so I need to include the library BEFORE the block (with the GMapShow component) is rendered. So, I have created a component to only include the Google Maps library: public class ImportGMapLib { @Inject private JavaScriptSupport javaScriptSupport; public void beginRender() { javaScriptSupport.importJavaScriptLibrary("https://maps.googleapis.com/maps/api/js?v=3.exp";); } } By the way, from T5.4 on, you can use https://, http:// and //: in @Import. Where's your JavaScript? How are you including it? That's probably the source of your problem. If you put your JavaScript code inside a .js file and included using @Import or JavaScriptSupport.importJavaScriptLibrary(), your code would be automatically included after the library you're using. 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. -- 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
RE: [T5] How can I validate if a script is present ?
Hi Thiago Ok, I will more specific: I'm developing a Tapestry component (GMapShow) that renders a google map. If I include the google maps javascript library directly in this component, the map is not render if the component is inside a block, so I need to include the library BEFORE the block (with the GMapShow component) is rendered. So, I have created a component to only include the Google Maps library: public class ImportGMapLib { @Inject private JavaScriptSupport javaScriptSupport; public void beginRender() { javaScriptSupport.importJavaScriptLibrary("https://maps.googleapis.com/maps/api/js?v=3.exp";); } } My "Test.tml" looks like this: refresh I need to validate from GMapEdit component if the javascript library "https://maps.googleapis.com/maps/api/js?v=3.exp"; was imported, or validate inside GMapEdit if the ImportGMapLib component was invoked inside Test.tml. Thanks in advance. -Mensaje original- De: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] Enviado el: jueves, 25 de septiembre de 2014 07:29 a.m. Para: Tapestry users Asunto: Re: [T5] How can I validate if a script is present ? On Wed, 24 Sep 2014 21:59:44 -0300, Carlos Gómez Montiel wrote: > Hi ¡ Hi! > How can I validate from a component if a script is inside tag > of a container page? I'm sorry, but I have no idea which scenario are you trying to describe here. Which validation is this? -- 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
Re: [T5] How can I validate if a script is present ?
On Wed, 24 Sep 2014 21:59:44 -0300, Carlos Gómez Montiel wrote: Hi ¡ Hi! How can I validate from a component if a script is inside tag of a container page? I'm sorry, but I have no idea which scenario are you trying to describe here. Which validation is this? -- 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