[Seaside] Updating non Smallfaces component.

Timothy James Ziebart timothy at churchmilitant.org
Wed Sep 23 18:30:10 UTC 2009


Hi Juan, 

well it is not working so I changed the strategy.  I will not be 
replacing the map but want to invoke a method to move the map (message 
is moveMap(coordinates).  The function will be created at the same time 
as the map pane.  So when the mapPane is  refreshed I want to call the 
moveMap javascript function.  Would I invoke the method in the 
refreshOn: method.  Such as:

LBCMapComponent>>refreshOn: aScript
     aScript add: (SUStream new
          nextPutAll: 'moveMap';
          arguments:#(coordinates);
          yourself).

So the flow would be as the selections change in the listboxes (there 
are 3), the map would be instructed to move to the coordinates.  This 
way the map is created once and manipulated from injecting the script.  
Thanks for the help. 

Tim


Burella Juan M. wrote:
> 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 <mailto: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 list
>>     seaside at lists.squeakfoundation.org <mailto:seaside at lists.squeakfoundation.org>
>>     http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>       
>
>
>
>
>     _______________________________________________
>     seaside mailing list
>     seaside at lists.squeakfoundation.org
>     <mailto:seaside at lists.squeakfoundation.org>
>     http://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
>   



More information about the seaside mailing list