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:'<div>marker 1 title</div><div>marker 1 body</div>'}, {latitude:xxx, longitude:yyy, infowindowhtml:'<div>marker 2 title</div><div>marker 2 body</div>'}, {latitude:xxx, longitude:yyy, infowindowhtml:'<div>marker 3 title</div><div>marker 3 body</div>'}, ] } 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 <lance.j...@googlemail.com> 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<GoogleMapMarker> getMarkers() { >> ... >> } >> >> Page.tml >> ============ >> <t:googlemap markers="markers" t:id="mygooglemap"> >> <p:infowindow> >> <div >> style="infowindow-title">${mygooglemap.currentmarker.data.title}</div> >> <div >> style="infowindow-body">${mygooglemap.currentmarker.data.body}</div> >> </p:infowindow> >> </t:googlemap> >> >> 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 >