Folks,
I made my first Cocoon widget :)
It isn't at all that hard, though I managed to waste time by trying to
subclass my widget from the Action class :(
Anyway, here's how to use it:
1) Definition document:
<fd:imagemap id="map">
<fd:hint>
<i18n:text>refresh.hint.mapZoomin</i18n:text>
</fd:hint>
<fd:on-action>
<javascript>onClickMap();</javascript>
</fd:on-action>
</fd:imagemap>
2) Template document:
<ft:widget id="map">
<fi:styling border="2"/>
</ft:widget>
3) No binding required.
4) Flow:
function onClickMap () {
var x= Number(cocoon.request.getParameter("map.x"));
var y= Number(cocoon.request.getParameter("map.y"));
var uri;
uri= "<zoomed map uri/>";
frm.getWidget().lookupWidget("map").setImageSource(uri);
}
So, the image map's URI is set by setImageSource(); when the user clicks
on it the onClickMap (or whatever is specified in on-action) flowscript
is called, which gets mouse coordinates from request parameters.
Simple, isn't it ?
If someone would like some features to be added, this is the right time
to speak... otherwise I'll make a zipball and donate the thing.
BTW, I'd like mouse coordinates to be retrieved by querying the map
widget rather than the request object... anyone knows a simple way to do
this from within the widget class (subclass of AbstractWidget) ?
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------