Re: tml parameter rendered into a JavaScript string
See http://tapestry.1045711.n5.nabble.com/Getting-the-HTML-markup-string-from-a-RenderCommand-td5564418.html On Friday, 24 February 2012, Lance Java wrote: > I am writing a google maps component which can display markers on a map, each marker has an info window when it is clicked on. I'd like to pass a parameter to the component containing the tml to render each marker's info window. > > eg: > > Page.java > > @InjectComponent > @Property > GoogleMap mygooglemap > > public List getMarkers() { >... > } > > Page.tml > > > > ${mygooglemap.currentmarker.data.title} > ${mygooglemap.currentmarker.data.body} > > > > The only thing is that the google maps api wants each marker's infowindow html to be a javascript string so I somehow need to use tapestry's template engine to generate strings for each marker's infowindow which I can then use to generate javascript. > > I have seen that the new Tree component can accept a "label" property which allows the user to provide a custom template for rendering each label. The label parameter is of type RenderCommand and RenderCommand has a single method: > > void render(MarkupWriter writer, RenderQueue queue); > > So, I was hoping that I could do the same sort of thing except that instead of rendering to the response MarkupWriter, I could pass an empty MarkupWriter to this method and then extract the generated markup somehow into a string to then use it to generate my javascript. > > Has anyone done this sort of thing before? > Am I on the right track or is there a simpler way?
RE: tml parameter rendered into a JavaScript string
Hi Lance, We prefer keep the model like this as a matter of separation of concerns, and let the user fill the model with his own server side logic. BTW, that didn't mean it's not possible to get a list of markers from a database. You can loop over a list of markers and fetch the marker infos from a database or a lucene search result : --- tml --- --- Java --- @Property private GMapMarkerModel currentMarker; public List getMarkers() { List list = new ArrayList(); // Fill list from Lucene or Database return list; } Laurent -Message d'origine- De : Lance Java [mailto:lance.j...@googlemail.com] Envoyé : lundi 27 février 2012 10:46 À : Tapestry users Objet : Re: tml parameter rendered into a JavaScript string Hi Laurent, I think the normal use case for using a google map would be to get a list of markers from a database search or from a lucene search result. Using your current implementation this would mean storing html in the database which I'd like to avoid. I would like to follow a similar pattern to the tapestry tree component where you do the following: ${tree.node.label} ${tree.node.label} The tapestry tree component requires a treeModel. As it iterates the treeModel, it updates the "node" property. Each tree node has a value property which is of generic type T and is the actual data (hibernate entity?) backing the treeNode which can be used to generate a custom label as I have done above. http://tapestry.apache.org/5.3.1/apidocs/src-html/org/apache/tapestry5/corelib/components/Tree.html As a suggestion for implementing this in your library, I would change GMapMarkerModel to GMapMarkerModel and had a public T getValue(). Then I would change the GMap component to update the "currentMarker" property each time it iterates the list. Then you could do something like: --- tml --- ${gmap.currentMarker.value.title} ${gmap.currentMarker.value.foo} ${gmap.currentMarker.value.bar} --- java --- @InjectComponent @Property private GMap gmap; public List getMarkers() { return getMarkersFromLuceneOrDatabaseEtc(); } Cheers, Lance. On Saturday, 25 February 2012, Guerin Laurent wrote: > Hi Lance, > > in fact, in my sample (Eiffel Tower example), i put html content into properties file but you're right : i agree that this could be easier to directly use block binding parameter or the GMap api support for passing the id of a > html element. > I'll try to add this feature in the next release. > > Tanks for your feedback. > > Laurent > > > De : Lance Java [lance.j...@googlemail.com] Date d'envoi : samedi 25 > février 2012 11:49 À : Tapestry users Objet : Re: RE : tml parameter > rendered into a JavaScript string > > Hi Laurent, > > I took a look at your library and from what I can see, it is missing > the functionality that I want. It seems that each marker has an info > property which is a string containing the text to render in the info > window. I would > like each marker's info window to contain complex html and I would > like to achieve this by passing a block (or perhaps a render command) > to the gmap component which will be used to render each marker's info window. > > I have noticed that the google map marker api supports passing the id > of a html element instead of the text content to show for an info > window. I think I will explore the option of rendering a hidden div > for each marker's > info window using a RenderCommand parameter and the MarkupWriter. I > will then pass the div id's to the gmap's javascript initializer so > that the info window div can be shown when a marker is clicked. > > Unless, of course, someone can tell me how to use tapestry's > templating engine to render strings on the serverside which I can pass > to the javascript initializer. I'm thinking that tapestry must be > doing this somewhere in order for MultiZoneUpdate to work? > > > On 25 February 2012 06:54, Guerin Laurent wrote: > >> Hi Lance, >> >> with exanpe-t5-lib, we provide a such component with markers and HTML >> InfoWindows : >> http://exanpe-t5-lib.appspot.com/components/googlemap/example2 >> >> If you want to build your own component, you can have a look at the source >> code : >> >> https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/java/fr/exanpe/t5/lib/components/GMap.java >> >> The JS part (l. 2809) : >> >> https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/resources/fr/exanpe/t5/lib/components
Re: tml parameter rendered into a JavaScript string
Hi Laurent, I think the normal use case for using a google map would be to get a list of markers from a database search or from a lucene search result. Using your current implementation this would mean storing html in the database which I'd like to avoid. I would like to follow a similar pattern to the tapestry tree component where you do the following: ${tree.node.label} ${tree.node.label} The tapestry tree component requires a treeModel. As it iterates the treeModel, it updates the "node" property. Each tree node has a value property which is of generic type T and is the actual data (hibernate entity?) backing the treeNode which can be used to generate a custom label as I have done above. http://tapestry.apache.org/5.3.1/apidocs/src-html/org/apache/tapestry5/corelib/components/Tree.html As a suggestion for implementing this in your library, I would change GMapMarkerModel to GMapMarkerModel and had a public T getValue(). Then I would change the GMap component to update the "currentMarker" property each time it iterates the list. Then you could do something like: --- tml --- ${gmap.currentMarker.value.title} ${gmap.currentMarker.value.foo} ${gmap.currentMarker.value.bar} --- java --- @InjectComponent @Property private GMap gmap; public List getMarkers() { return getMarkersFromLuceneOrDatabaseEtc(); } Cheers, Lance. On Saturday, 25 February 2012, Guerin Laurent wrote: > Hi Lance, > > in fact, in my sample (Eiffel Tower example), i put html content into properties file but you're right : i agree that this could be easier to directly use block binding parameter or the GMap api support for passing the id of a > html element. > I'll try to add this feature in the next release. > > Tanks for your feedback. > > Laurent > > > De : Lance Java [lance.j...@googlemail.com] > Date d'envoi : samedi 25 février 2012 11:49 > À : Tapestry users > Objet : Re: RE : tml parameter rendered into a JavaScript string > > Hi Laurent, > > I took a look at your library and from what I can see, it is missing the > functionality that I want. It seems that each marker has an info property > which is a string containing the text to render in the info window. I would > like each marker's info window to contain complex html and I would like to > achieve this by passing a block (or perhaps a render command) to the gmap > component which will be used to render each marker's info window. > > I have noticed that the google map marker api supports passing the id of a > html element instead of the text content to show for an info window. I > think I will explore the option of rendering a hidden div for each marker's > info window using a RenderCommand parameter and the MarkupWriter. I will > then pass the div id's to the gmap's javascript initializer so that the > info window div can be shown when a marker is clicked. > > Unless, of course, someone can tell me how to use tapestry's templating > engine to render strings on the serverside which I can pass to the > javascript initializer. I'm thinking that tapestry must be doing this > somewhere in order for MultiZoneUpdate to work? > > > On 25 February 2012 06:54, Guerin Laurent wrote: > >> Hi Lance, >> >> with exanpe-t5-lib, we provide a such component with markers and HTML >> InfoWindows : >> http://exanpe-t5-lib.appspot.com/components/googlemap/example2 >> >> If you want to build your own component, you can have a look at the source >> code : >> >> https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/java/fr/exanpe/t5/lib/components/GMap.java >> >> The JS part (l. 2809) : >> >> https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/resources/fr/exanpe/t5/lib/components/js/exanpe-t5-lib.js >> >> Laurent. >> >> >> De : Lance Java [lance.j...@googlemail.com] >> Date d'envoi : vendredi 24 février 2012 17:37 >> À : Tapestry users >> Objet : Re: tml parameter rendered into a JavaScript string >> >> It seems I'm having troubles explaining what it is I'm trying to do. I need >> an implementation for generateInfoWindowHtml() in the code below. >> >> @Import(library="mygooglemap.js") >> public class GoogleMap { >>@Inject >>JavaScriptSupport jsSupport; >> >>@Parameter(required=true) >>RenderCommand infoWindow; >> >>@Parameter(required=true) >>List markers; >> >>
RE : RE : tml parameter rendered into a JavaScript string
Hi Lance, in fact, in my sample (Eiffel Tower example), i put html content into properties file but you're right : i agree that this could be easier to directly use block binding parameter or the GMap api support for passing the id of a html element. I'll try to add this feature in the next release. Tanks for your feedback. Laurent De : Lance Java [lance.j...@googlemail.com] Date d'envoi : samedi 25 février 2012 11:49 À : Tapestry users Objet : Re: RE : tml parameter rendered into a JavaScript string Hi Laurent, I took a look at your library and from what I can see, it is missing the functionality that I want. It seems that each marker has an info property which is a string containing the text to render in the info window. I would like each marker's info window to contain complex html and I would like to achieve this by passing a block (or perhaps a render command) to the gmap component which will be used to render each marker's info window. I have noticed that the google map marker api supports passing the id of a html element instead of the text content to show for an info window. I think I will explore the option of rendering a hidden div for each marker's info window using a RenderCommand parameter and the MarkupWriter. I will then pass the div id's to the gmap's javascript initializer so that the info window div can be shown when a marker is clicked. Unless, of course, someone can tell me how to use tapestry's templating engine to render strings on the serverside which I can pass to the javascript initializer. I'm thinking that tapestry must be doing this somewhere in order for MultiZoneUpdate to work? On 25 February 2012 06:54, Guerin Laurent wrote: > Hi Lance, > > with exanpe-t5-lib, we provide a such component with markers and HTML > InfoWindows : > http://exanpe-t5-lib.appspot.com/components/googlemap/example2 > > If you want to build your own component, you can have a look at the source > code : > > https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/java/fr/exanpe/t5/lib/components/GMap.java > > The JS part (l. 2809) : > > https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/resources/fr/exanpe/t5/lib/components/js/exanpe-t5-lib.js > > Laurent. > > > De : Lance Java [lance.j...@googlemail.com] > Date d'envoi : vendredi 24 février 2012 17:37 > À : Tapestry users > Objet : Re: tml parameter rendered into a JavaScript string > > It seems I'm having troubles explaining what it is I'm trying to do. I need > an implementation for generateInfoWindowHtml() in the code below. > > @Import(library="mygooglemap.js") > public class GoogleMap { >@Inject >JavaScriptSupport jsSupport; > >@Parameter(required=true) >RenderCommand infoWindow; > >@Parameter(required=true) >List markers; > >@Parameter(required=true) >double centerLatitude; > >@Parameter(required=true) >double centerLongitude; > >@Parameter(required=true) >int zoom; > > >@SetupRender >void setupRender() { >JSONObject mapInitializer = createInitializerJsonObject(); >jsSupport.addScript("initGoogleMap(%s)", mapInitializer); >} > >private JSONObject createInitializerJsonObject() { >JSONObject init = new JSONObject(); >JSONArray markerInits = new JSONArray(); >for (GoogleMapMarker marker : markers) { >JSONObject markerInit = new JSONObject(); >markerInit.put("latitude", marker.getLatitude()); >markerInit.put("longitude", marker.getLongitude()); >markerInit.put("infoWindowHtml", > generateInfoWindowHtml(marker)); >} >init.put("centerLatutude", centerLatitude); >init.put("centerLongitude", centerLongitude); >init.put("zoom", zoom); >init.put("markers", markerInits); > >return init; >} > >private String generateInfoWindowHtml(GoogleMapMarker marker) { >// Use tapestry's template engine to generate html using > marker and infoWindow >} > > } > > - > 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: RE : tml parameter rendered into a JavaScript string
Hi Laurent, I took a look at your library and from what I can see, it is missing the functionality that I want. It seems that each marker has an info property which is a string containing the text to render in the info window. I would like each marker's info window to contain complex html and I would like to achieve this by passing a block (or perhaps a render command) to the gmap component which will be used to render each marker's info window. I have noticed that the google map marker api supports passing the id of a html element instead of the text content to show for an info window. I think I will explore the option of rendering a hidden div for each marker's info window using a RenderCommand parameter and the MarkupWriter. I will then pass the div id's to the gmap's javascript initializer so that the info window div can be shown when a marker is clicked. Unless, of course, someone can tell me how to use tapestry's templating engine to render strings on the serverside which I can pass to the javascript initializer. I'm thinking that tapestry must be doing this somewhere in order for MultiZoneUpdate to work? On 25 February 2012 06:54, Guerin Laurent wrote: > Hi Lance, > > with exanpe-t5-lib, we provide a such component with markers and HTML > InfoWindows : > http://exanpe-t5-lib.appspot.com/components/googlemap/example2 > > If you want to build your own component, you can have a look at the source > code : > > https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/java/fr/exanpe/t5/lib/components/GMap.java > > The JS part (l. 2809) : > > https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/resources/fr/exanpe/t5/lib/components/js/exanpe-t5-lib.js > > Laurent. > > > De : Lance Java [lance.j...@googlemail.com] > Date d'envoi : vendredi 24 février 2012 17:37 > À : Tapestry users > Objet : Re: tml parameter rendered into a JavaScript string > > It seems I'm having troubles explaining what it is I'm trying to do. I need > an implementation for generateInfoWindowHtml() in the code below. > > @Import(library="mygooglemap.js") > public class GoogleMap { >@Inject >JavaScriptSupport jsSupport; > >@Parameter(required=true) >RenderCommand infoWindow; > >@Parameter(required=true) >List markers; > >@Parameter(required=true) >double centerLatitude; > >@Parameter(required=true) >double centerLongitude; > >@Parameter(required=true) >int zoom; > > >@SetupRender >void setupRender() { >JSONObject mapInitializer = createInitializerJsonObject(); >jsSupport.addScript("initGoogleMap(%s)", mapInitializer); >} > >private JSONObject createInitializerJsonObject() { >JSONObject init = new JSONObject(); >JSONArray markerInits = new JSONArray(); >for (GoogleMapMarker marker : markers) { >JSONObject markerInit = new JSONObject(); >markerInit.put("latitude", marker.getLatitude()); >markerInit.put("longitude", marker.getLongitude()); >markerInit.put("infoWindowHtml", > generateInfoWindowHtml(marker)); >} >init.put("centerLatutude", centerLatitude); >init.put("centerLongitude", centerLongitude); >init.put("zoom", zoom); >init.put("markers", markerInits); > >return init; >} > >private String generateInfoWindowHtml(GoogleMapMarker marker) { >// Use tapestry's template engine to generate html using > marker and infoWindow >} > > } > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
RE : tml parameter rendered into a JavaScript string
Hi Lance, with exanpe-t5-lib, we provide a such component with markers and HTML InfoWindows : http://exanpe-t5-lib.appspot.com/components/googlemap/example2 If you want to build your own component, you can have a look at the source code : https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/java/fr/exanpe/t5/lib/components/GMap.java The JS part (l. 2809) : https://github.com/exanpe/exanpe-t5-lib/blob/master/src/main/resources/fr/exanpe/t5/lib/components/js/exanpe-t5-lib.js Laurent. De : Lance Java [lance.j...@googlemail.com] Date d'envoi : vendredi 24 février 2012 17:37 À : Tapestry users Objet : Re: tml parameter rendered into a JavaScript string It seems I'm having troubles explaining what it is I'm trying to do. I need an implementation for generateInfoWindowHtml() in the code below. @Import(library="mygooglemap.js") public class GoogleMap { @Inject JavaScriptSupport jsSupport; @Parameter(required=true) RenderCommand infoWindow; @Parameter(required=true) List markers; @Parameter(required=true) double centerLatitude; @Parameter(required=true) double centerLongitude; @Parameter(required=true) int zoom; @SetupRender void setupRender() { JSONObject mapInitializer = createInitializerJsonObject(); jsSupport.addScript("initGoogleMap(%s)", mapInitializer); } private JSONObject createInitializerJsonObject() { JSONObject init = new JSONObject(); JSONArray markerInits = new JSONArray(); for (GoogleMapMarker marker : markers) { JSONObject markerInit = new JSONObject(); markerInit.put("latitude", marker.getLatitude()); markerInit.put("longitude", marker.getLongitude()); markerInit.put("infoWindowHtml", generateInfoWindowHtml(marker)); } init.put("centerLatutude", centerLatitude); init.put("centerLongitude", centerLongitude); init.put("zoom", zoom); init.put("markers", markerInits); return init; } private String generateInfoWindowHtml(GoogleMapMarker marker) { // Use tapestry's template engine to generate html using marker and infoWindow } } - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: tml parameter rendered into a JavaScript string
While I'm sure it could be made to work with addScript IMHO it's just not the right way. @SetupRender void setupRender() { js.addInitializerCall("GoogleMap", createInitializerJsonObject()); } Then in mygooglemap.js (I use jquery but it's more or less the same for prototype) (function($){ /** Container of functions that may be invoked by the Tapestry.init() function. */ $.extend(Tapestry.Initializer, { GoogleMap: function(specs){ //specs will be your JSONObject } }); })(jQuery); When your page loads Tapestry will call your initializer for each JSONObject you add. It also works for zones. addScript gets tricky for zones. -- View this message in context: http://tapestry.1045711.n5.nabble.com/tml-parameter-rendered-into-a-JavaScript-string-tp5512889p5513362.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: tml parameter rendered into a JavaScript string
It seems I'm having troubles explaining what it is I'm trying to do. I need an implementation for generateInfoWindowHtml() in the code below. @Import(library="mygooglemap.js") public class GoogleMap { @Inject JavaScriptSupport jsSupport; @Parameter(required=true) RenderCommand infoWindow; @Parameter(required=true) List markers; @Parameter(required=true) double centerLatitude; @Parameter(required=true) double centerLongitude; @Parameter(required=true) int zoom; @SetupRender void setupRender() { JSONObject mapInitializer = createInitializerJsonObject(); jsSupport.addScript("initGoogleMap(%s)", mapInitializer); } private JSONObject createInitializerJsonObject() { JSONObject init = new JSONObject(); JSONArray markerInits = new JSONArray(); for (GoogleMapMarker marker : markers) { JSONObject markerInit = new JSONObject(); markerInit.put("latitude", marker.getLatitude()); markerInit.put("longitude", marker.getLongitude()); markerInit.put("infoWindowHtml", generateInfoWindowHtml(marker)); } init.put("centerLatutude", centerLatitude); init.put("centerLongitude", centerLongitude); init.put("zoom", zoom); init.put("markers", markerInits); return init; } private String generateInfoWindowHtml(GoogleMapMarker marker) { // Use tapestry's template engine to generate html using marker and infoWindow } }
Re: tml parameter rendered into a JavaScript string
Perhaps it's not clear what you want but I think javaScriptSupport.addInitializerCall does exactly what you need if you create a Tapestry initializer in you javascript file. it puts your JSONObject into the html and then calls your javascript function in the initializer with each JSONObject as an argument. -- View this message in context: http://tapestry.1045711.n5.nabble.com/tml-parameter-rendered-into-a-JavaScript-string-tp5512889p5513139.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: tml parameter rendered into a JavaScript string
Hi Thiago, I realise that I will need to use JavascriptSupport and an imported .js file to achieve this. My question is about generating the JsonObject serverside which will be used in JavascriptSupport.addScript(). I need to have a javascript string containing the infowindow html (see http://code.google.com/apis/maps/documentation/javascript/overlays.html#InfoWindows ). I'm guessing that my JsonObject will look something like { markers:[ {latitude:xxx, longitude:yyy, infowindowhtml:'marker 1 titlemarker 1 body'}, {latitude:xxx, longitude:yyy, infowindowhtml:'marker 2 titlemarker 2 body'}, {latitude:xxx, longitude:yyy, infowindowhtml:'marker 3 titlemarker 3 body'}, ] } So I need to generate each infowindowhtml using tapestry's templating engine to merge the current marker object with the template (passed as a parameter to the component). On Friday, 24 February 2012, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > If you need to generate JavaScript, do it by using JavaScriptSupport and imported .js files. > > On Fri, 24 Feb 2012 12:05:46 -0200, Lance Java wrote: > >> I am writing a google maps component which can display markers on a map, >> each marker has an info window when it is clicked on. I'd like to pass a >> parameter to the component containing the tml to render each marker's info >> window. >> >> eg: >> >> Page.java >> >> @InjectComponent >> @Property >> GoogleMap mygooglemap >> >> public List getMarkers() { >> ... >> } >> >> Page.tml >> >> >> >> > style="infowindow-title">${mygooglemap.currentmarker.data.title} >> > style="infowindow-body">${mygooglemap.currentmarker.data.body} >> >> >> >> The only thing is that the google maps api wants each marker's infowindow >> html to be a javascript string so I somehow need to use tapestry's template >> engine to generate strings for each marker's infowindow which I can then >> use to generate javascript. >> >> I have seen that the new Tree component can accept a "label" property which >> allows the user to provide a custom template for rendering each label. The >> label parameter is of type RenderCommand and RenderCommand has a single >> method: >> >>void render(MarkupWriter writer, RenderQueue queue); >> >> So, I was hoping that I could do the same sort of thing except that instead >> of rendering to the response MarkupWriter, I could pass an empty >> MarkupWriter to this method and then extract the generated markup somehow >> into a string to then use it to generate my javascript. >> >> Has anyone done this sort of thing before? >> Am I on the right track or is there a simpler way? > > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate > http://www.arsmachina.com.br >
Re: tml parameter rendered into a JavaScript string
If you need to generate JavaScript, do it by using JavaScriptSupport and imported .js files. On Fri, 24 Feb 2012 12:05:46 -0200, Lance Java wrote: I am writing a google maps component which can display markers on a map, each marker has an info window when it is clicked on. I'd like to pass a parameter to the component containing the tml to render each marker's info window. eg: Page.java @InjectComponent @Property GoogleMap mygooglemap public List getMarkers() { ... } Page.tml ${mygooglemap.currentmarker.data.title} ${mygooglemap.currentmarker.data.body} The only thing is that the google maps api wants each marker's infowindow html to be a javascript string so I somehow need to use tapestry's template engine to generate strings for each marker's infowindow which I can then use to generate javascript. I have seen that the new Tree component can accept a "label" property which allows the user to provide a custom template for rendering each label. The label parameter is of type RenderCommand and RenderCommand has a single method: void render(MarkupWriter writer, RenderQueue queue); So, I was hoping that I could do the same sort of thing except that instead of rendering to the response MarkupWriter, I could pass an empty MarkupWriter to this method and then extract the generated markup somehow into a string to then use it to generate my javascript. Has anyone done this sort of thing before? Am I on the right track or is there a simpler way? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
tml parameter rendered into a JavaScript string
I am writing a google maps component which can display markers on a map, each marker has an info window when it is clicked on. I'd like to pass a parameter to the component containing the tml to render each marker's info window. eg: Page.java @InjectComponent @Property GoogleMap mygooglemap public List getMarkers() { ... } Page.tml ${mygooglemap.currentmarker.data.title} ${mygooglemap.currentmarker.data.body} The only thing is that the google maps api wants each marker's infowindow html to be a javascript string so I somehow need to use tapestry's template engine to generate strings for each marker's infowindow which I can then use to generate javascript. I have seen that the new Tree component can accept a "label" property which allows the user to provide a custom template for rendering each label. The label parameter is of type RenderCommand and RenderCommand has a single method: void render(MarkupWriter writer, RenderQueue queue); So, I was hoping that I could do the same sort of thing except that instead of rendering to the response MarkupWriter, I could pass an empty MarkupWriter to this method and then extract the generated markup somehow into a string to then use it to generate my javascript. Has anyone done this sort of thing before? Am I on the right track or is there a simpler way?