[mapguide-users] Fusion 2.0 domObj

Paul Spencer pagameba at gmail.com
Thu Feb 19 13:09:35 EST 2009


Ok, I'll try to highlight the major things for upgrading widgets ...

Things that have changed in Widget sub-classes:

* remove inheritance from Fusion.Tool.ButtonBase and add uiClass:  
Jx.Button
* remove inheritance from Fusion.Tool.MenuBase and add uiClass: Jx.Menu
* add setUiObject method for widgets that need to add stuff to a menu  
(see ViewOptions)
* change initialize to initializeWidget
* add isExclusive: true for widgets that are 'modal' on the map
* change execute method to activate

The key change that you need to understand, Mark, is the one about  
setUiObject.  Due to an architectural change in how widgets are  
constructed, widgets typically do not have a domObj any more.  What  
they do have is a uiObj which is some representation of the widget in  
the user interface.  For reasons that escape me right now, the uiObj  
is not available when the widget is created so I added a setUiObject  
method to handle the association of a uiObj with a widget.  The  
particular uiObj that is created for any given widget is controlled by  
its uiClass member (which is null by default).

When a new widget is created, if it has a uiClass set then the  
framework creates a new instance of the uiClass and gives it to the  
widget via the setUiObject.  If no uiClass is specified then element  
from the dom with the id that causes the widget to be created is  
passed (i.e. a reference to a <div>).

The base Widget class provides a default implementation of setUiObject  
that does the grunt work of making buttons, menus etc work properly,  
especially if the widget is considered modal on the map.  For widgets  
that are not using a uiClass (which would be your case), you will need  
to add a setUiObject method to your widget to handle inserting your ui  
into what was previously the domObj.

I believe the code in initializeWidget that tests if domObj is valid  
is never used now and it is probably there by mistake.

You should be able to copy the setUiObject method from EditableScale  
into your widget and replace the appendChild calls to do the  
appropriate thing.

Hope this helps

Paul

On 19-Feb-09, at 11:55 AM, Mark Pendergraft wrote:

> I have a widget which I’m trying to port to the 2.0 beta and in the  
> past I used “this.domObj.appendChild()” to add an input box to the  
> widget, but now that code breaks saying that the domObj is null.  I  
> noticed in the EditableScale widget that an if (this.domObj)  
> statement is used to see if the domObj is valid.  My question is:   
> Do I need to wait for a certain event to happen before creating this  
> widget?  Right now my code never adds the input box, but the  
> EditableScale code does.
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users



More information about the mapguide-users mailing list