[Cartoweb-users] Cannot clear drop-down list selections

Oliver Christen oliver.christen at camptocamp.com
Wed Oct 21 08:42:03 EST 2009


Dear Miguel

as far as I can see, the View plugin has never been adapted to be used with
ajax. so any action done through ajax will not update the piece of template
with the view inputs.

adapting a plugin to response to ajax is not really complicated though and
if you feel at ease with php, you should be able to do it.
note that in this case, a full ajaxification of the plugin is not needed.
here is what should be done:

in ClientView.php
- add Ajaxable to the list of "implements" in the plugin class definition.
- add an ajaxGetPluginResponse function to return the plugin template. it
should return the same as the existing renderForm function. all ajaxified
plugin now have a common function renderFormPrepare which is used by both
ajaxGetPluginResponse and renderForm.
- add a ajaxHandleAction function, it only need to contains
"$pluginEnabler->enablePlugin('view');"
(look at ClientOutline.php and ClientBboxHistory.php for examples)

- create a new View.ajax.js file, using the same structure as the related
file in other plugins (look atBboxHistory.ajax.js), but you dont need to
define any action, simply change the code in the handleResponse function so
the html returned from php is updated correctly in the template. Because
javascript need an element id as target to be able to replace it's content,
you may have to enclose the whole view template inside a <div
id="choose_an_id_which_make_sens">...</div> (for example
$('bbox_history_form') will access the div <div id="bbox_history_form">
...</div>)
- add that new View.ajax.js file in your cartoclient.tpl header
- clean your cache with a cw3setup --clean
and your should be done.

have a look at the plugin outline and BboxHistory, the modifications are
quite straightforward.
also more details are available in the doc about ajax elements and pieces of
code http://www.cartoweb.org/doc_head/docbook/xhtml/user.ajax.html

kind regards
Oliver

2009/10/21 Miguel Juston <juston at smem.fr>

>  Hi Oliver,
>
> Find below a dump from the jsTracer. But I first would like to thank you
> for the somehow obvious tip: "Check the log!!" ;) The scale issue was due to
> a missing <div> - recenter_scale_div - around the scale dd list in my
> template. I've fixed it and it works like a charm! I could not spot anything
> related to the view issue I'm facing though. I thought the pb could come
> from my custom template and reverted to the standard one but no luck. Any
> idea why my 'viewActive' checkbox is not in the parameter list?
>
> Here is the dump:
>
> ********** BEGIN ******************
>
> --- Action Location.Pan triggered ---
>
> Calling Location.Pan onBeforeAjaxCall()
>
> Calling plugin onBeforeAjaxCallGeneral()
> Calling AjaxPlugins.Location.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Layers.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Images.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Query.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Tables.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Outline.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.Search.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.BboxHistory.onBeforeAjaxCallGeneral
> Calling AjaxPlugins.CartoMessages.onBeforeAjaxCallGeneral
>
> Calling AjaxPlugins.Common.onBeforeAjaxCall()
> Initiating AJAX request
> Pending actions: 1
> GET params:
> ajaxActionRequest=Location.Pan&
> POST params:
> posted=1&js_folder_idx=8&selection_type=point&selection_coords=729278.1553393255,1596596.8010671334&features=&project=SIGdev&fake_reset=&fake_query=&outline_label_text=votre
> titre&recenter_doit=0&tool=pan&openNodes=&layers[]=Commune&layers[]=Section&layers[]=Parcelle&layers[]=Ortho&outline_point_symbol=fleche_droite&outline_point_color=#f0dc69&outline_point_size=10&outline_line_size=3&outline_line_transparency=100&outline_line_color=#ff0000&outline_polygon_transparency=20&outline_polygon_outline_color=#000000&outline_polygon_background_color=#ff9900&shortcut_doit=0&id_recenter_layer=&id_recenter_ids=&query_layer=&query_select=&null=1&insee=&search_config=commune&search_sort_column=&search_sort_direction=asc&search_number=&search_page=1&search_offset=10&search_area_min=&search_area_max=&query_clear=0&viewTitle=St
> Anne&author=Miguel&viewLocationUpdate=0&handleView=0&viewUpdateId=2&viewDeleteId=2&viewDelete=0&recenter_scale=0&mapsize=2&shortcut_id=-1&search_commune=-1&search_area=0-999999999&viewLoadTitleId=2&viewLocationId=3&
> Waiting for response...
> Response received!
> Plugins that gave response: location images bboxHistory cartoMessages
>
> Updating GUI for plugin Location
> Updating dhtmlAPI's bbox and factor properties...
> AjaxHandler.updateDomElement(): Updating recenter_scale_div element's
> innerHTML's value...
> AjaxHandler.updateDomElement(): Updating currentScale element's innerHTML's
> value...
> AjaxHandler.updateDomElement(): Updating location_info element's
> innerHTML's value...
> Warning: given element (location_info) was not found in the DOM!
>
> Updating GUI for plugin Images
> AjaxHandler.updateDomElement(): Updating keymap element's src's value...
> Warning: given element (keymap) was not found in the DOM!
> AjaxHandler.updateDomElement(): Updating scalebar element's src's value...
> AjaxHandler.updateDomElement(): Updating map_drawing element's
> style.display's value...
>
> Updating GUI for plugin BboxHistory
>
> Updating GUI for plugin CartoMessages
> Developer messages: 3
>    * Warning: you have a high number of generated images (782 [warning
> threshold 500]]). You should run the following instruction in a command line
> prompt: php cw3setup.php --clean
>    * getMap request time: 1.264822 (wrong if mapResult cache hit)
>    * array (  'ajaxActionRequest' => 'Location.Pan',  'posted' => '1',
> 'js_folder_idx' => '8',  'selection_type' => 'point',  'selection_coords' =>
> '729278.1553393255,1596596.8010671334',  'features' => '',  'project' =>
> 'SIGdev',  'fake_reset' => '',  'fake_query' => '',  'outline_label_text' =>
> 'votre titre',  'recenter_doit' => '0',  'tool' => 'pan',  'openNodes' =>
> '',  'layers' =>   array (    0 => 'Commune',    1 => 'Section',    2 =>
> 'Parcelle',    3 => 'Ortho',  ),  'outline_point_symbol' =>
> 'fleche_droite',  'outline_point_color' => '#f0dc69',  'outline_point_size'
> => '10',  'outline_line_size' => '3',  'outline_line_transparency' =>
> '100',  'outline_line_color' => '#ff0000',  'outline_polygon_transparency'
> => '20',  'outline_polygon_outline_color' => '#000000',
> 'outline_polygon_background_color' => '#ff9900',  'shortcut_doit' => '0',
> 'id_recenter_layer' => '',  'id_recenter_ids' => '',  'query_layer' => '',
> 'query_select' => '',  'null' => '1',  'insee' => '',  'search_config' =>
> 'commune',  'search_sort_column' => '',  'search_sort_direction' => 'asc',
> 'search_number' => '',  'search_page' => '1',  'search_offset' => '10',
> 'search_area_min' => '',  'search_area_max' => '',  'query_clear' => '0',
> 'viewTitle' => 'St Anne',  'author' => 'Miguel',  'viewLocationUpdate' =>
> '0',  'handleView' => '0',  'viewUpdateId' => '2',  'viewDeleteId' => '2',
> 'viewDelete' => '0',  'recenter_scale' => '0',  'mapsize' => '2',
> 'shortcut_id' => '-1',  'search_commune' => '-1',  'search_area' =>
> '0-999999999',  'viewLoadTitleId' => '2',  'viewLocationId' => '3',
> 'LangCookie' => 'fr',  'CW3_current_project_cookie' => 'SIGdev',
> 'TestCookie' => 'OK',  'jsTrace' => '-2px 818px 360px 190px',  '__utma' =>
> '169880226.498649291.1253289754.1253289754.1253289754.1',  '__utmz' =>
> '169880226.1253289754.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
> 'PHPSESSID' => '7816cdccae723f4e4513fbdc7adcc77d',)
>
> User messages: 0
>
> Calling Location.Pan onAfterAjaxCall()
>
> Calling AjaxPlugins.Common.onAfterAjaxCall()
> Clearing DHTML drawings...
> Clearing stored features...
>
> Calling plugin onAfterAjaxCallGeneral()
> Calling AjaxPlugins.Location.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Layers.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Images.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Query.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Tables.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Outline.onAfterAjaxCallGeneral
> Calling AjaxPlugins.Search.onAfterAjaxCallGeneral
> Calling AjaxPlugins.BboxHistory.onAfterAjaxCallGeneral
> Calling AjaxPlugins.CartoMessages.onAfterAjaxCallGeneral
>
> --- Action Location.Pan complete ---
>
> ********** END ******************
>
>
>
>
> Cheers,
> Miguel
>
>
>
> Oliver Christen a écrit :
>
> hi
> can you tell me what is displayed in the JSTraceDebugger windows after a
> zoom ?
> simply clear the window's log and do a zoom action then copy the tracelog
>
> 2009/10/20 Miguel Juston <juston at smem.fr>
>
>> Hi all,
>>
>> This is my first email to this list and I think I should introduce
>> myself before bugging you with my newbie problems!
>>
>> My name is Miguel, I'm a French IT developer in charge of the migration
>> of an existing SIG to Cartoweb. I'm based in Martinque, a French island
>> in the Caribeans.
>>
>> I've been working on Cartoweb for a month now and I've had a project up
>> and running pretty easily. The archives of this mailing list have been a
>> great help, I must say! But today, I cannot figure out how to solve this
>> one by myself. Any help / tips would be much appreciated.
>>
>> Some drop-down lists of my project don't seem to clear properly. For
>> instance, the pre-defined scale d-d list stays stuck on whatever the
>> user chooses. Then, any attempts to change the zoom and/or recenter will
>> fail. Actually, recentering will work but the scale will remain the
>> same. On the demos, when one selects a predefined scale, any zoom in/out
>> will clear the scale selection. Not on my project.
>>
>> Similarly, the View plugin does not work properly. When I load a view,
>> I'm stuck on it although 'Memorize this view' is not checked. In facts,
>> this checkbox does not have any effect. So, once a view is loaded,
>> scrolling or zooming won't clear the saved views drop down list.
>>
>> This all seems odd to me. I just can't figure out what's going on. Any
>> ideas?
>>
>> Thanks for you help
>>
>> Cheers,
>> Miguel
>>
>>
>>
>> _______________________________________________
>> Cartoweb-users mailing list
>> Cartoweb-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20091021/e2d9e93f/attachment-0001.htm 


More information about the Cartoweb-users mailing list