Good day Cristiano,<br><br>All of the documentation that is currently available for fusion resides at <a href="http://trac.osgeo.org/fusion/wiki/Documentation" target="_blank">http://trac.osgeo.org/fusion/wiki/Documentation</a> unfortunately the docs there are kind of stale. <br>
<br>Read up on the API docs for these two. <br><a href="http://jxlib.org/" target="_blank">http://jxlib.org/</a> - The UI Toolkit fusion uses<br>
<a href="http://mootools.net/docs/core" target="_blank">http://mootools.net/docs/core</a> - the underlying technology that JX uses<br><br>and of course - Openlayers <a href="http://trac.openlayers.org/wiki/Documentation" target="_blank">http://trac.openlayers.org/wiki/Documentation</a><br>

<br>Someone should create some better documentation for fusion however until then. I&#39;ve created a little widget that does a lot of the possible workflow in fusion; <br><br>in your ApplicationDefinition add this block:<br>
<br>   &lt;Widget&gt;<br>      &lt;Name&gt;MyNewWidget&lt;/Name&gt;<br>      &lt;Type&gt;MyNewWidget&lt;/Type&gt;<br>      &lt;Label&gt;MyNewWidget&lt;/Label&gt;<br>      &lt;StatusItem/&gt;<br>      &lt;Extension&gt;<br>
        &lt;Foo&gt;fooness&lt;/Foo&gt;<br>        &lt;Bar&gt;barness&lt;/Bar&gt;<br>      &lt;/Extension&gt;<br>    &lt;/Widget&gt;<br><br>and in your html template add this<br><br>&lt;div id=&quot;MyNewWidget&quot;&gt;&lt;/div&gt;<br>
<br>Here is the JS for the widget: copy this code to /fusion/widgets/MyNewWidget.js<br><br>/**<br> * Fusion.Widget.MyNewWidget<br> *<br> *<br> * Copyright (c) 20010, DM Solutions Group Inc.<br> * Permission is hereby granted, free of charge, to any person obtaining a<br>
 * copy of this software and associated documentation files (the &quot;Software&quot;),<br> * to deal in the Software without restriction, including without limitation<br> * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
 * and/or sell copies of the Software, and to permit persons to whom the<br> * Software is furnished to do so, subject to the following conditions:<br> *<br> * The above copyright notice and this permission notice shall be included<br>
 * in all copies or substantial portions of the Software.<br> *<br> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br> * DEALINGS IN THE SOFTWARE.<br> */<br><br> /********************************************************************<br> * Class: Fusion.Widget.MyNewWidget<br>
 *<br> * create a widget that does nothing useful except to illustrate some of the ways widgets work<br> *<br> * **********************************************************************/<br><br>/* <br>Lets create a custon event called &#39;MY_NEW_WIDGET_CUSTOM_EVENT&quot;<br>
*/<br><br>Fusion.Event.MY_NEW_WIDGET_CUSTOM_EVENT = Fusion.Event.lastEventId++;<br><br>/* <br> Lets create the widget class<br>*/<br>Fusion.Widget.MyNewWidget = OpenLayers.Class(Fusion.Widget, {<br>    isExclusive: true,<br>
    uiClass: Jx.Button,<br>    foo:&#39;SOMETHING&#39;,<br>    bar:&#39;ELSE&#39;,<br>                                             <br>     initializeWidget: function(widgetTag){<br>          alert(&#39;MyNewWidget:initializeWidget fired&#39;);<br>
          console.dir(arguments);<br><br>          //Set the appDef variables. <br>          var json = widgetTag.extension;<br>          this.foo = json.Foo ? json.Foo[0] : this.foo;<br>          this.bar = json.Bar ? json.Bar[0] : this.bar;<br>
<br>          console.log(&#39;MyNewWidget:initializeWidget:foo=&#39;+this.foo);<br>          console.log(&#39;MyNewWidget:initializeWidget:bar=&#39;+this.bar);<br><br>          // lets register the event in fusion<br>          this.registerEventID(Fusion.Event.MY_NEW_WIDGET_CUSTOM_EVENT);<br>
<br>          // Lets register this widget for the MY_NEW_WIDGET_CUSTOM_EVENT event. <br>          this.registerForEvent(Fusion.Event.MY_NEW_WIDGET_CUSTOM_EVENT, OpenLayers.Function.bind(this.widgetCustomEvent, this));<br>
<br>          // Lets register this widget for the MAP_ACTIVE_LAYER_CHANGED event. <br>          this.getMap().registerForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, OpenLayers.Function.bind(this.doSomething, this));<br>
     },<br>    <br>    activate : function() {<br>         // this function is fired when the JX.button is pressed and initially when the widget is &quot;activated&quot;<br>          alert(&#39;MyNewWidget:activate fired&#39;);<br>
          alert(&#39;foo = &#39;+this.foo);<br>          /* <br>          Lets do something with /fusion/layers/MapServer/php/SomePHPScript.php and send over the session and mapname so we can interact with<br>          the map session. then fire doSomethingElse with the returned JSON. <br>
          <br>          To do this we need the arch, session and mapname. <br>          */<br>          var map = this.getMap().aMaps[0];   <br>          var sl = Fusion.getScriptLanguage();<br>          var queryScript = &#39;layers/&#39; + map.arch + &#39;/&#39; + sl  + &#39;/SomePHPScript.&#39; + sl;<br>
          var params = {<br>            &#39;mapname&#39;: map._sMapname,<br>            &#39;session&#39;: map.getSessionID()<br>          };<br>          var ajaxOptions = {<br>               // when the ajax is done return to &quot;doSomethingElse&quot;<br>
               onSuccess: OpenLayers.Function.bind(this.doSomethingElse, this),<br>               method: &#39;GET&#39;,<br>               parameters: params<br>          };<br>          // fire the ajax request<br>          Fusion.ajaxRequest(queryScript, ajaxOptions);         <br>
    },<br><br>    deactivate : function() {<br>         alert(&#39;MyNewWidget:deactivate fired&#39;);<br>    },<br><br>    execute: function (position, altZoom) {<br>         alert(&#39;MyNewWidget:execute fired&#39;);<br>
    },<br><br>    doSomething: function(){<br>         // this is fired when the MAP_ACTIVE_LAYER_CHANGED event is triggered. <br>         alert(&#39;MyNewWidget:doSomething: fired&#39;);<br>    },<br><br>    doSomethingElse: function(r){<br>
         // this is the callback to &quot;activate&quot; when the ajaxrequest returns. <br>         alert(&#39;MyNewWidget:doSomethingElse: fired&#39;);<br>         if (r.status == 200) {<br>            var o;<br>            eval(&#39;o=&#39;+r.responseText);<br>
            alert(&#39;MyNewWidget:doSomethingElse:JSON: &#39;+o.mapname);<br>         }<br>         // lets fire our custom event. <br>         this.triggerEvent(Fusion.Event.MY_NEW_WIDGET_CUSTOM_EVENT);<br>    },<br>     widgetCustomEvent: function(event,r){<br>
          /*    <br>               This is triggered from the custom event MY_NEW_WIDGET_CUSTOM_EVENT<br>               once an event has been registerd in fusion you can call this event from any other widget. <br>          */<br>
         alert(&#39;MyNewWidget:widgetCustomEvent: fired&#39;);<br>     }<br>});<br><br><br>
Here is the PHP for the widget: copy this code to /fusion/layers/MapServer/php/MyNewWidget.js<br><br>&lt;?php<br>/**<br> * SomePhpScript<br> *<br><br> * Portions copyright (c) 2006, DM Solutions Group Inc.<br> * Portions copyright (c) 2008, ENPLAN<br>
 * Permission is hereby granted, free of charge, to any person obtaining a<br> * copy of this software and associated documentation files (the &quot;Software&quot;),<br> * to deal in the Software without restriction, including without limitation<br>
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br> * and/or sell copies of the Software, and to permit persons to whom the<br> * Software is furnished to do so, subject to the following conditions:<br>
 *<br> * The above copyright notice and this permission notice shall be included<br> * in all copies or substantial portions of the Software.<br> *<br> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br> * DEALINGS IN THE SOFTWARE.<br> */<br><br>/* set up the session */<br>
include(dirname(__FILE__).&#39;/../../../common/php/Utilities.php&#39;);<br>include(dirname(__FILE__).&#39;/Common.php&#39;);<br>include(dirname(__FILE__).&#39;/Utilities.php&#39;);<br><br>header(&#39;Content-type: application/json&#39;);<br>
header(&#39;X-JSON: true&#39;);<br><br>if (!isset($mapName)) {<br>    die(&quot;{&#39;error&#39;:&#39;mapname not set&#39;}&quot;);<br>}<br><br>if (isset($_SESSION[&#39;maps&#39;]) &amp;&amp; isset($_SESSION[&#39;maps&#39;][$mapName])) {<br>
    $oMap = ms_newMapObj($_SESSION[&#39;maps&#39;][$mapName]);<br>    <br>     if ($oMap) {<br>          for ($i=0;$i&lt;$oMap-&gt;numlayers;$i++) {<br>             // do something with the layers. <br>             $layer = $oMap-&gt;getLayer($i);<br>
          }<br>        <br>     // save the mapfile. <br>     $oMap-&gt;save($_SESSION[&#39;maps&#39;][$mapName]);    <br><br>     $oTmp = NULL;<br>     $oTmp-&gt;mapname = $oMap-&gt;name;<br>     echo json_encode($oTmp);<br>
     }<br>     else<br>     {<br>          echo &quot;{&#39;error&#39;:&#39;Coud not open the mapfile.&#39;}&quot;;<br>     }<br>}<br>else<br>{<br>echo &quot;{&#39;error&#39;:&#39;Session or mapname not set.&#39;}&quot;;<br>
}<br>?&gt;<br><br><br>Hope this helps<br><br>Cheers<br><br>Paul D. <br><br>-- <br>    Paul Deschamps<br>    Applications Specialist<br>    DM Solutions Group Inc.<br><br>    Office: (613) 565-5056 x28<br>    <a href="mailto:pdeschamps@dmsolutions.ca" target="_blank">pdeschamps@dmsolutions.ca</a><br>

    <a href="http://www.dmsolutions.ca" target="_blank">http://www.dmsolutions.ca</a><br>    <a href="http://research.dmsolutions.ca" target="_blank">http://research.dmsolutions.ca</a><br>    <br><br>