So, with the need to update the root, I think this would work equally well as a simple renderable object in 2.8 but it wouldn&#39;t really be be much better than a component or brush.<div><br></div><div>With a 2.9 Painter, you can implement #updateRoot: on the Painter subclass itself so the map object would be able to encapsulate all of that. This does require, as you point out, that the Painter be added to #children, of course, but I think that&#39;s better than having to implement your own root updating behaviour and not unexpected for the user.</div>
<div><br></div><div>Your renderContentOn: would look basically the same as your version with either a painter or a renderable object:</div><div><br></div><div>MyComponent&gt;&gt;#renderContentOn: html<br>       html render: (GoogleMap new<br>
               class: &#39;myMap&#39;;<br>               setCenter: 45.5267 @ -122.8390 zoom: 11;</div><div>               &quot;...&quot;</div><div>               yourself)<br><br></div><div>So I think the result is slightly better with a Painter in the sense of implementing #children, rather then update root behaviour.</div>
<div><br></div><div>The other advantage is more theoretical and that is that a painter is not dependent on the encapsulating component using Canvas as its renderer. I say this is pretty theoretical because the only other renderer right now is the RSS one. :) From an architectural point of view, though, components are able to use any renderer they want and if they&#39;re using one that doesn&#39;t support your brush, well they couldn&#39;t easily use your implementation.</div>
<div><br></div><div>This is all pretty subtle. Thus the debate. :)</div><div><br></div><div>Julian</div><div><br><div class="gmail_quote">On Thu, Jun 18, 2009 at 5:49 PM, James Foster <span dir="ltr">&lt;<a href="mailto:Smalltalk@jgfoster.net">Smalltalk@jgfoster.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Julian,<br>
<br>
I did the GoogleMaps stuff several months ago and was only comparing component and brush; I didn&#39;t consider a Painter mostly from lack of knowledge (and being on a 2.8 environment). I wasn&#39;t aware that there was a debate about when to use brushes; I thought it was just me who couldn&#39;t figure it out!<br>

<br>
I ended up with a Brush because it felt more like I was just defining a special &lt;div&gt; and I didn&#39;t want to require people to define a child component. I figured that until I needed something more complicated I&#39;d stay with the simplest thing that could possibly work (tm), and the brush approach came together nicely. Once I started thinking about GoogleMaps as being little more than a fancy div/listbox/image, several things fell out quite cleanly. I discovered that I don&#39;t want to keep any state and that I want to treat the configuration as one does with other things. For example (where all of the messages to the brush are optional, but #setCenter:zoom: is most useful):<br>

<br>
MyComponent&gt;&gt;#renderContentOn: html<br>
<br>
        html googleMap<br>
                class: &#39;myMap&#39;;<br>
                setCenter: 45.5267 @ -122.8390 zoom: 11;<br>
                enableGoogleBar;<br>
                addType: GMapType physical;<br>
                addControl: GControl largeMapControl;<br>
                setUIToDefault;<br>
                on: &#39;zoomEnd&#39; do: [:x :y :z |<br>
                        &#39;alert(&quot;Zoom from &#39; , x printString , &#39; to &#39; , y printString ,<br>
                        &#39; (see GMUsingLatLong&gt;&gt;renderContentOn:)&quot;);&#39;];<br>
                yourself.<br>
<br>
The only other requirement is that the component needs to allow some #updateRoot: behavior:<br>
<br>
MyComponent&gt;&gt;#updateRoot: anHtmlRoot<br>
<br>
        super updateRoot: anHtmlRoot.<br>
        self updateRootWithGoogleMaps: anHtmlRoot.<br>
<br>
The implementation involves creating various scripts and feeding them out, but it works fine in the brush.<br>
<br>
GoogleMap&gt;&gt;#with: anObject<br>
<br>
        self ensureId.<br>
        super with: [<br>
                anObject renderOn: canvas.<br>
                canvas html: self mapScript.<br>
        ].<br>
        self addLoadScript: self variable , &#39;Init()&#39;.<br>
<br>
Overall it seemed less intrusive for the library client to use a brush rather than a component. Other than #updateRoot:, there isn&#39;t really much to do. With a component there were so many things that were brush-like, including setting the class, id, style, etc., and more issues (does it need to be included as a child?). I was able to do so much without state, that it just seemed nice this way. It seemed like I got further than any of the other GoogleMaps packages I found, but I&#39;d love to see another approach or get expert feedback on what I&#39;ve done.<br>

<br>
In general, while I&#39;m heavily involved in Seaside from the GemStone point-of-view, there is still a great deal for me to learn about when to use different parts of the framework. This exercise was another opportunity to learn and I did learn something!<br>
<font color="#888888">
<br>
James</font><div><div></div><div class="h5"><br>
<br>
On Jun 18, 2009, at 5:15 PM, Julian Fitzell wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
James,<br>
<br>
It&#39;s been a while since I looked at the google maps stuff so I don&#39;t recall... what do you actually render to the page? If memory serves, you only need to output stuff that can be generated by the standard brushes (divs and JS or something, right?) and you don&#39;t need to put content inside it.<br>

<br>
I have no memory of whether there is anything that requires a component to keep state but it doesn&#39;t *seem* at first glance to me like something that needs to be a brush either. I don&#39;t mean to suggest you&#39;re wrong since you&#39;ve obviously gone through the exercise and I haven&#39;t but there&#39;s quite a bit of debate now and then over when to use brushes. I&#39;m just wondering whether you considered a renderable object (a Painter in 2.9) as an option or just component/brush. And if you ruled out the third option, is there a particular reason you think a brush is more appropriate?<br>

<br>
Julian<br>
<br>
On Thu, Jun 18, 2009 at 4:00 PM, James Foster &lt;<a href="mailto:Smalltalk@jgfoster.net" target="_blank">Smalltalk@jgfoster.net</a>&gt; wrote:<br>
Mariano,<br>
<br>
I&#39;ll be interested to see how this comes out. As I mentioned earlier, I started with a component and switched to a brush. I came to view the GoogleMap as a browser widget, something like a listbox, where you give it some data and let it draw itself. Yes, you can configure callbacks, but that isn&#39;t really different from other brushes. What sort of &#39;state&#39; do you envision keeping with the map? Might that be better in a domain-specific component that wraps a map? I was able to implement over 40 examples and have not yet found a need to get more complex.<br>

<br>
James<br>
<br>
On Jun 18, 2009, at 2:58 PM, Mariano Montone wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Julian. I think a component will be ok.<br>
<br>
Mariano<br>
<br>
On Thu, Jun 18, 2009 at 1:22 PM, Julian Fitzell &lt;<a href="mailto:jfitzell@gmail.com" target="_blank">jfitzell@gmail.com</a>&gt; wrote:<br>
Hi Mariano,<br>
<br>
Off the top of my head, if I were implementing a google maps package, I would do it as a component or a painter (see below). Brushes certainly aren&#39;t intended to be kept around so if you have state to persist between requests that&#39;s not the way to go.<br>

<br>
There are people who like implementing everything as brushes but the main functionality of brushes is that they can be selected in arbitrary orders to nest content within each other, e.g.:<br>
<br>
html div: [ html span: [ html paragraph: &#39;foo&#39; ] ].<br>
<br>
Unless you plan to do be able to do:<br>
<br>
html div: [ html googleMap: [ html paragraph: &#39;foo&#39; ] ]<br>
<br>
(i.e. unless the thing you are creating allows content to be put inside it) I don&#39;t think there&#39;s much advantage in making your own brush. (The other reason to consider using brushes of course is that they have more direct access to the document).<br>

<br>
Even if you don&#39;t need the benefits of components (see <a href="http://blog.fitzell.ca/2009/05/when-to-use-seaside-component.html" target="_blank">http://blog.fitzell.ca/2009/05/when-to-use-seaside-component.html</a> ), you can just create a renderable object by implementing #renderOn: and do:<br>

<br>
html render: (GoogleMaps new configSomeStuff; yourself)<br>
<br>
This process is made much clearer in 2.9 where you can subclass WAPainter, implement #rendererClass to control what kind of renderer you get passed (you might possibly implement the google maps thing *using* one or more custom brushes and have your own renderer for them), and implement #renderContentOn: as you would for a component.<br>

<br>
Hopefully that makes things clearer and not muddier. :)<br>
<br>
Julian<br>
<br>
On Thu, Jun 18, 2009 at 5:51 AM, Mariano Montone &lt;<a href="mailto:marianomontone@gmail.com" target="_blank">marianomontone@gmail.com</a>&gt; wrote:<br>
Hello!,<br>
           I&#39;m implementing an API for rendering Google Maps. I&#39;ve decided to implement it as a brush. That&#39;s because I&#39;m just generating javascript code. But now I have a problem: when adding support for callbacks, I need to hold some state; for example, the map the callback refers to. But I think brushes are not meant to hold state, that is something left for the components mechanism, isn&#39;t it? So I would like to know what would be the correct way of implementing it in the framework. Should I implement maps as components, or should I add state to my brushes; I may hold a state in the callback block too, but I don&#39;t think that&#39;s good.<br>

<br>
Thanks!<br>
<br>
Mariano<br>
<br>
<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote>
<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote>
<br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</div></div></blockquote></div><br></div>