You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Gabriele Columbro <co...@gmail.com> on 2006/11/24 19:27:19 UTC

Ajaxifying the ImageMap widget

Hi devs!
I'm currently working togheter with Luca Morandini on a GIS project based on
Cocoon 2.1.9, of course using the ImageMap [1] widget that Luca contributed
nearly one year ago.
After having developed the whole application (based on Geoserver [2] as
WMS/WFS server and Weblogic 9.2 as appserver) in the plain old full page
refresh mode, we had a sudden requirement change that forced us to switch to
a more buzz-word driven ( Ajax ;-) ) approach.
All went smoothly (ajax=true is almost the only change I needed, making
bosses astonished, thx guys) until I had to make the imagemap widget value
change after am XHR (i.e. update the src of the input type="image" that
represents the map and tells geoserver how to draw the map). I discovered,
in fact, that the ImageMap widget was never calling the

org/apache/cocoon/forms/formmodel/Form.java#addWidgetUpdate(
org.apache.cocoon.forms.formmodel.Widget)

method, that then triggers the Browser update process.
Once I patched this (of course planning to contribute it, but waiting for a
completely working version) all actions performed on other widgets *but the
map* were correctly reflected on a partial update on the map (in case its
server side state was modified), but I'm now facing a different problem
handling clicks *on* the map:  whereas a full page submit on an input
type="image" sends two parameters ( /widgetId.x/ and /widgetId.y/ , i.e. the
coordinates of the mouse click) that are used to recompute map extent, the
XHR is just not sending this parameters (verified with tcpmon), so that map
status does not get modified, and map not redrawn.
I'm stuck as I don't know where to take action, wheter if it's a dojo
framework lack (I'm using the jar that is contained in cocoon 2.1.9, should
I try with the latest trunk?), or it's a problem of the dojo-cocoon js
bridge.
It would be great if someone can point me to the right direction, also
because I think that this can be a good (and contributable) improvement for
the imagemap widget to support AJAX, in a web world where ajax maps are now
the standard.

WDYT?

Thanks in advance,
Gabriele



[1] http://cocoon.apache.org/2.1/userdocs/widgets/widget_imagemap.html
[2] http://docs.codehaus.org/display/GEOS/Home




-----------------------------------------
Eng. Gabriele Columbro
Consultant at Sourcesense Italy
-----------------------------------------
work: g.columbro@pronetics.it
private: columbro@gmail.com
mobile: (0039)3201612846

yahoo: g.columbro
gtalk: columbro@gmail.com
AIM:   gabrielecolumbro

-----------------------------------------
"Keyboard not found.
Press F1 to continue"
-----------------------------------------

Re: Ajaxifying the ImageMap widget

Posted by Gabriele Columbro <co...@gmail.com>.
Ciao Jeremy!
Good to hear from you again...

On 11/25/06, Jeremy Quinn <je...@apache.org> wrote:
>
> Ciao Gabriele


<snip/>


>
> Your problem lies here, I think :
>
>         src/blocks/forms/java/org/apache/cocoon/forms/resources
> /js/common.js
>
> in cocoon.forms.buildQueryString line: 109 :
>
>          if (input.type == "submit" || input.type == "image" ||
> input.type == "button") {
>              // Skip buttons
>              continue;
>          }
>
> Your image-type input is not added to the query string.


Not implemented indeed.
Guess that doing it can be a wise thing anyway, to conform to W3C specs [1],
apart from the fact that I like maps every day more, and it may be useful
for giving cocoon a simple map support.

You could patch this function to output what you need.



Yep, that's exactly the kind of snippet I was looking for ;-)


Alternatively it is possible call cocoon.forms.CFormsForm.submit
> (name, params) directly and pass the 'name' of the submitting control
> and extra form parameters in 'params' (an associative array).


Probably by now I'll use a quick'n'dirty solution for my project (i.e. pass
the coordinates of the click via the "params" associative array), mainly for
two reasons:
- I'm working on Cocoon 2.1.9 (but on a framework with 2.1.8 forms-styling
xsls)
- I need customer feedback quite urgently :-)

This has changed in 2.1.10-dev, as I re-wrote all of this stuff to
> add the ability to send XHR via IframeIO if there are file-type
> inputs. I threw the buildQueryString function away and use Dojo's
> built-in code for assembling the form.


Ok, then of course the quick'n'dirty solution won't be contributable in the
current trunk, I guess ;-)

HTH
>
> regards Jeremy
>
>
> PS. Are you sure this will look good though ? If what you are doing
> is just re-centering the map on the new coords, I'd be tempted to
> write a Dojo WIdget to handle this itself, give you a smooth scroll
> to the new centre (everyone is used to Google Maps etc.) rather than
> replace the image using BrowserUpdate. (Just my humble opinion ;))


This sounds cool  ;-)
I started approaching the dojo/cocoon task recently and particularly this
weekend, so, who knows, I may write (or find ;-) ) a dojo map widget for the
2.1.10 dev. The only concern is that in my case (a WMS/WFS server generating
the map, geoserver) most of the map processing, and actual rendering, is
done (also quite heavily, no tiling) on the server side, and *a singleton*
img url is used as a contract to define the exact image that server must
generate. Writing a dojo widget only for this use case is probably out of my
scope a the moment.
Probably it may be worth to do a generic widget that is configurable with
different services, say gmaps, map24 and a generic opensource map server (
e.g. Geoserver).  I'll definitely let you know!

Thanks for all your help

Gab

[1]  http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.5


-----------------------------------------
Eng. Gabriele Columbro
Consultant at Sourcesense Italy
-----------------------------------------
work: g.columbro@pronetics.it
private: columbro@gmail.com
mobile: (0039)3201612846

yahoo: g.columbro
gtalk: columbro@gmail.com
AIM:   gabrielecolumbro

-----------------------------------------
"Keyboard not found.
Press F1 to continue"
-----------------------------------------

Re: Ajaxifying the ImageMap widget

Posted by Gabriele Columbro <co...@gmail.com>.
Hi Jeremy,
been quite busy in the last days but had some progresses anyway in the
imagemap side:
the quick'n'dirty solution (with a modified version of the buildQueryString
function) is properly working, updating the map at every click. So cool
stuff!
Probably not worth committing the whole js stuff for sending imagemap.x and
imagemap.y request-params (as it's based on the 2.1.9 ajax support) but
maybe only the ImageMap.java widget support for BrowserUpdate (via
autoadding to form.updatedWidgets).
WDYT?

On 11/25/06, Jeremy Quinn <je...@apache.org> wrote:
>
> Ciao Gabriele


 <snip/>

HTH
>
> regards Jeremy
>
>
> PS. Are you sure this will look good though ? If what you are doing
> is just re-centering the map on the new coords, I'd be tempted to
> write a Dojo WIdget to handle this itself, give you a smooth scroll
> to the new centre (everyone is used to Google Maps etc.) rather than
> replace the image using BrowserUpdate. (Just my humble opinion ;))



You were right though, probably the best solution is to implement a dojo
widget for handling map and feature update client side (also because I'm not
allowed to add arbitrary content on the map, say POI, after the browser
update transformer, or at least I don't like a tricky solution).
A good point to start may be this [1]. WDYT?
IMHO It's pretty fast and seems "mainstream" dojo ;-)
I would like to first try integrate it, and then maybe generalize it for non
tiled maps and for different POI rendering models.
I'm svn-upping the 2.1.10-dev branch so I can first check out changes you
made to the ajax support before integrating or working on it.
BTW are those changes also reflected in the trunk? Just to know which is the
expected longevity of the work I'm going to do ;-)


Ciao!

Gabriele


[1] http://archive.dojotoolkit.org/nightly/tests/widget/test_GoogleMap.html
(thanks to Valerio for pin-pointing me to this link ;-) )

-----------------------------------------
Eng. Gabriele Columbro
Consultant at Sourcesense Italy
-----------------------------------------
work: g.columbro@pronetics.it
private: columbro@gmail.com
mobile: (0039)3201612846

yahoo: g.columbro
gtalk: columbro@gmail.com
AIM:   gabrielecolumbro

-----------------------------------------
"Keyboard not found.
Press F1 to continue"
-----------------------------------------

Re: Ajaxifying the ImageMap widget

Posted by Jeremy Quinn <je...@apache.org>.
Ciao Gabriele

On 24 Nov 2006, at 18:27, Gabriele Columbro wrote:

> Hi devs!
> I'm currently working togheter with Luca Morandini on a GIS project  
> based on Cocoon 2.1.9, of course using the ImageMap [1] widget that  
> Luca contributed nearly one year ago.
> After having developed the whole application (based on Geoserver  
> [2] as WMS/WFS server and Weblogic 9.2 as appserver) in the plain  
> old full page refresh mode, we had a sudden requirement change that  
> forced us to switch to a more buzz-word driven ( Ajax ;-) ) approach.
> All went smoothly (ajax=true is almost the only change I needed,  
> making bosses astonished, thx guys) until I had to make the  
> imagemap widget value change after am XHR ( i.e. update the src of  
> the input type="image" that represents the map and tells geoserver  
> how to draw the map). I discovered, in fact, that the ImageMap  
> widget was never calling the
>
> org/apache/cocoon/forms/formmodel/Form.java#addWidgetUpdate 
> ( org.apache.cocoon.forms.formmodel.Widget)
>
> method, that then triggers the Browser update process.
> Once I patched this (of course planning to contribute it, but  
> waiting for a completely working version) all actions performed on  
> other widgets *but the map* were correctly reflected on a partial  
> update on the map (in case its server side state was modified), but  
> I'm now facing a different problem handling clicks *on* the map:   
> whereas a full page submit on an input type="image" sends two  
> parameters ( /widgetId.x/ and /widgetId.y/ , i.e. the coordinates  
> of the mouse click) that are used to recompute map extent, the XHR  
> is just not sending this parameters (verified with tcpmon), so that  
> map status does not get modified, and map not redrawn.
> I'm stuck as I don't know where to take action, wheter if it's a  
> dojo framework lack (I'm using the jar that is contained in cocoon  
> 2.1.9, should I try with the latest trunk?), or it's a problem of  
> the dojo-cocoon js bridge.
> It would be great if someone can point me to the right direction,  
> also because I think that this can be a good (and contributable)  
> improvement for the imagemap widget to support AJAX, in a web world  
> where ajax maps are now the standard.

Your problem lies here, I think :

	src/blocks/forms/java/org/apache/cocoon/forms/resources/js/common.js

in cocoon.forms.buildQueryString line: 109 :

         if (input.type == "submit" || input.type == "image" ||  
input.type == "button") {
             // Skip buttons
             continue;
         }

Your image-type input is not added to the query string.

You could patch this function to output what you need.

Alternatively it is possible call cocoon.forms.CFormsForm.submit 
(name, params) directly and pass the 'name' of the submitting control  
and extra form parameters in 'params' (an associative array).


This has changed in 2.1.10-dev, as I re-wrote all of this stuff to  
add the ability to send XHR via IframeIO if there are file-type  
inputs. I threw the buildQueryString function away and use Dojo's  
built-in code for assembling the form.


HTH

regards Jeremy


PS. Are you sure this will look good though ? If what you are doing  
is just re-centering the map on the new coords, I'd be tempted to  
write a Dojo WIdget to handle this itself, give you a smooth scroll  
to the new centre (everyone is used to Google Maps etc.) rather than  
replace the image using BrowserUpdate. (Just my humble opinion ;))