[Seaside] Updating non Smallfaces component.

Burella Juan M. juan.burella at gmail.com
Thu Sep 17 05:44:11 UTC 2009


Hi Tim,

Yes, the problem is #refreshOn: and...I think you need to call #replace.
>From what I've seen of the GoogleMap component,
you could do something like this

LBCMapComponent>>refreshOn: aScript

    aScript element
        id: self styleId;
        replace:[:render | render render: self].

    aScript add: (SUStream new
            nextPutAll:  '(',self map updateMapScript, ').call';
            arguments: #();
            yourself).


LBCGoogleMap>>updateMapScript

    | myStream listenerString functionString |
    myStream := (WriteStream on: String new)
        nextPutAll: 'function ';
        nextPutAll: 'updateMap(){'; cr; tab;
        nextPutAll: 'if(google.maps.BrowserIsCompatible()){'; cr; tab; tab;
        nextPutAll: 'var mapOptions=';
        yourself.
    options printOn: myStream.
    myStream
        nextPutAll: ';'; cr; tab; tab;
        nextPutAll: 'var map=new
google.maps.Map2(document.getElementById("';
        nextPutAll: htmlID;
        nextPutAll: '"),mapOptions);'; cr; tab; tab;
        nextPutAll: '// *** custom script below'; cr;
        nextPutAll: stream contents; cr; tab; tab;
        nextPutAll: '// *** custom script above'; cr; tab; tab;
        nextPutAll: variable;
        nextPutAll: '=map;';
        yourself.
    listenerString := 'google.maps.Event.addListener(' , variable , ', "'.
    functionString := self functionString.
    eventHandlers keysDo: [:event |
        myStream cr; tab; tab;
            nextPutAll: listenerString;
            nextPutAll: event;
            nextPutAll: functionString;
            nextPutAll: event;
            nextPutAll: '&x=" + x + "&y=" + y + "&z=" + z)'; cr; tab; tab;
            nextPutAll: '});    // end anonymous function and
addListener()';
            yourself.
    ].
    ^myStream cr; tab;
        nextPutAll: '}    // end BrowserIsCompatible()'; cr;
        nextPutAll: '}    // end ';
        nextPutAll: variable;
        nextPutAll: 'Init()'; cr;
        contents.

Maybe it isn't the best solution, but it should work fine
Cheers,
Juan M.


On Wed, Sep 16, 2009 at 10:05 PM, Timothy James Ziebart <
timothy at churchmilitant.org> wrote:

>  Ok gentlemen I am hoping you can comment on whether or not this has been
> done properly.  I have created two subpanes (there are 8 in total).  By the
> way I have 3 listboxes dynamically changing the list contents -- so it is
> working perfectly but for one hurdle.
>
> *createMapPane
>     | pane |
>
>     pane := LBCMapComponent new.
>     pane name: 'mapDisplay'.
>     pane styleId: self liveMapId.
>     pane model: model.
>     ^pane.*
>
> *createRegionListBox
>     | pane panes list |
>     list := self session findCodeByParent: 'region'.
>     panes := OrderedCollection
>                 with: (self paneNamed: 'nhoodList')
>                 with: (self paneNamed: 'cityList')
>                 with: (self paneNamed: 'mapDisplay').
>     pane := SFListBox new.
>     pane name: 'regionList';
>          items: list;
>          lines: 5;
>          printSelector: #asString;
>          owner: self;
>
>         when: #changed:
>         send: #regionSelectionChanged:
>         to: self
>         refresh: panes.
>     ^ pane
> *
>
> The map pane is to be updated when a change has been triggered in
> regionList.  When regionList is change the regionSelectionChanged method is
> called which in turn calls updatePane when completed.
>
> *updatePane
>     self updateRegionPane; updateCityPane; updateHoodPane; updateMapPane*
>
> The updateMapPane executes the following:
>
> *updateMapPane
>     | pane newpane|
>
>     pane := self paneNamed: 'mapDisplay'.
>     newpane := LBCMapComponent new.
>     newpane
>         model: model;
>         styleId: self liveMapId;
>         name: 'mapDisplay'.
>
>     self replacePane: pane with: newpane.*
>
> which in turn fires the refreshOn: method is on LBCMapComponent.
>
> *refreshOn: aScript
>
>     aScript element
>         id: self styleId;
>         replace:[:render | render render: self].
>
>     "I am not sure what needs to be done here"
>     aScript add: [ ]*
>
> which will in turn execute renderOn:
>
> *renderOn: html
>     |myMap|
>     myMap := self map.
>
>     myMap renderOn: html.*
>
> where map returns
>
> *map
>
>     ^LBCGoogleMap new
>         setCenter: model coordinates zoom: model zoom;
>         setUIToDefault;
>         yourself.*
>
> All the components are updated correctly however the map does not redraw.
> If I refresh the browser than the map draws correctly -- so it has to do
> with the script in the refreshOn method, correct?  If so I, my ignorance of
> javascript has left me at a loss as to what needs to be done.  Do I need to
> call replace?  Any suggestions?  Thank you in advance.
>
>  _______________________________________________
> seaside mailing listseaside at lists.squeakfoundation.orghttp://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20090917/8bd1e4af/attachment-0001.htm


More information about the seaside mailing list