[fusion-users] Widget Functions.

Tómas Guðmundsson tomas at snertill.is
Wed May 14 11:02:41 EDT 2008


Hi all.

Thanks all for all the conversations. I finally made it possible to 
load an external javascript file, which is exactly like Paul said. 
It is an library that I want to use on many occasions to block the 
map. You can never be too careful against, ..., in-experienced users.

But yeah, I needed: 
1) Fusion.require('widgets/myLibrary.js');
2) var library = new Fusion.Widget. myLibrary(widgetTag);

And widgetTag is something that is needed as well. Anyways, everybody
has been a huge help. I like this a lot.

Kind regards from Iceland.
Tómas.

-----Original Message-----
From: fusion-users-bounces at lists.osgeo.org [mailto:fusion-users-bounces at lists.osgeo.org] On Behalf Of Paul Spencer
Sent: 14. maí 2008 14:47
To: Alan Boudreault
Cc: fusion-users at lists.osgeo.org
Subject: Re: [fusion-users] Widget Functions.

Alan is right, there is a way of forcing code to be included using  
require.  And your sneBlockUI seems more like a common library rather  
than a widget so this is a better way of getting it in there  
(especially if it is shared by several widgets in the end - require  
only includes the code once regardless of how many times it is  
require'd.

If you don't use require, then you have to make sure that you have  
both a <Widget> tag in your application and that the template refers  
to the widget, either by name directly (by including an element in the  
page with an id the same as the <Name> tag) or through a container as  
you did.

This is by design so that you can use several templates with the same  
ApplicationDefinition and have different functionality exposed in  
each.  However, it may be useful to have a way of including widgets  
that don't have a natural UI.  To do this now, you have to put a place  
holder in the HTML template which feels like a hack to work around the  
library.  I'd like to have a way to have a UI-less widget be included  
without needing to work around the architecture of the system.

I'm open to suggestions - I was thinking that if the Name tag was left  
empty, then the widget would be both loaded and instantiated when the  
application is launched.

Cheers

Paul

On 14-May-08, at 10:32 AM, Alan Boudreault wrote:

> I just checked something... and i think you use the Fusion.require  
> method in your sneRefreshMap definition file.
> ie: Fusion.require(widgets/myRequiredWidget.js');
>
> This will avoid to add extra unuseful information in the  
> ApplicationDefinition.xml.
>
> Regards,
> Alan
>
> Tómas Guðmundsson wrote:
>> I tried what you guys said. Here is the block I added. Note my  
>> widget is called sneBlockUI.
>>
>> ApplicationDefinition.xml:
>> <!-- ******************************************
>> * Trying to load extra javascripts
>> * with xml here. Required by fusion.
>> **********************************************-->
>> <Container xsi:type="UiItemContainerType">
>>  <Name>sneBlockUI</Name>
>>  <Type>Block UI</Type>
>>   <Item xsi:type="WidgetItemType">
>>     <Function>Widget</Function>
>>     <Widget>sneBlockUI</Widget>      </Item>    </Container>
>> index.html:
>> <div id="sneBlockUI"></div>
>>
>> Do I need to add the widget (xml) definition for sneBlockUI as well ?
>>
>> -----Original Message-----
>> From: fusion-users-bounces at lists.osgeo.org [mailto:fusion-users-bounces at lists.osgeo.org 
>> ] On Behalf Of Mike Adair
>> Sent: 14. maí 2008 13:52
>> To: Alan Boudreault
>> Cc: fusion-users at lists.osgeo.org
>> Subject: Re: [fusion-users] Widget Functions.
>>
>> Also, widgets must be associated with a DOM element to be  
>> instantiated.  This can be either through a <Container><Item>  
>> element, or simply through a <div id='widgetName'> element in the  
>> page (I think this works).  You can try putting a breakpoint in the  
>> widget constructor to see if it ever gets instantiated.
>>
>> Mike
>>
>> Alan Boudreault wrote:
>>
>>> Where is defined you class sneBlockUI ? Can you check with firebug  
>>> if the file you defined this class is well loaded ? Fusion does'nt  
>>> load all the "TheWidget.js" files by default,  only those that are  
>>> required. (Those defined in the ApplicationDefinition.xml)
>>>
>>> Regards,
>>> Alan
>>>
>>> Tómas Guðmundsson wrote:
>>>
>>>> Yeah,
>>>>
>>>> Here are the errors I get via firebug.
>>>> Fusion.Widget.sneBlockUI is not a constructor
>>>> - this.blocker = new Fusion.Widget.sneBlockUI();  ---  
>>>> sneRefreshMap.js (line 8)
>>>> blockUI is not defined
>>>> - blockUI(); --- sneRefreshMap.js (line 16)
>>>>
>>>> What I am aiming for is this blocking of the ui while the map is  
>>>> rendering so maybe I should just modify the Map.js ?
>>>> However here is the code.
>>>>
>>>> Fusion.Widget.sneRefreshMap = Class.create();
>>>> Fusion.Widget.sneRefreshMap.prototype =  {
>>>>    initialize : function(widgetTag) {
>>>>        //console.log('RefreshMap.initialize');
>>>>        Object.inheritFrom(this, Fusion.Widget.prototype,  
>>>> [widgetTag, true]);
>>>>        Object.inheritFrom(this, Fusion.Tool.ButtonBase.prototype,  
>>>> []);
>>>>        this.dialog = null;
>>>>        this.blocker = new Fusion.Widget.sneBlockUI();
>>>>    },
>>>>
>>>>    /**
>>>>     * execute function.
>>>>     */
>>>>    execute : function() {
>>>>        var map = this.getMap();
>>>>        blockUI();
>>>>        map.redraw();                   },
>>>>        blockUI : function() {
>>>>        if (!this.dialog) {
>>>>        var size = Element.getPageDimensions();
>>>>        var o = {
>>>>            title: OpenLayers.String.translate('Loading'),
>>>>            id: 'Loading',
>>>>            imageBaseUrl: this.imageBaseUrl,
>>>>            width: 150,
>>>>            height: 85,
>>>>            resizeable: false,
>>>>            top: (size.height-200)/2,
>>>>            left: (size.width-320)/2,
>>>>        };
>>>>    this.dialog = new Jx.Dialog(o);
>>>>    }
>>>>
>>>>        this.dialog.open();            }
>>>> };
>>>>
>>>> -----Original Message-----
>>>> From: Paul Spencer [mailto:pspencer at dmsolutions.ca] Sent: 14. maí  
>>>> 2008 11:25
>>>> To: Tómas Guðmundsson
>>>> Cc: fusion-users at lists.osgeo.org
>>>> Subject: Re: [fusion-users] Widget Functions.
>>>>
>>>> I'm not sure about the first error, can you send code for us to  
>>>> look at?
>>>>
>>>> For the second, try:
>>>>
>>>> var myObject = new Fusion.Widget.MyNewWidget();
>>>>
>>>> Paul
>>>>
>>>> On 14-May-08, at 5:57 AM, Tómas Guðmundsson wrote:
>>>>
>>>>
>>>>> Hi all.
>>>>>
>>>>> I have been wondering about a very strange "bug" but then again  
>>>>> this  might be something that you don't notice until you've told  
>>>>> everybody  about it and feel like a complete idiot.
>>>>>
>>>>> I'm trying to create a code that extends the refresh widget by   
>>>>> opening up a ui-blocking page like the Print widget does.  
>>>>> However,  if I just use the pure code from Print.js, like copy/ 
>>>>> paste. Firebug  gives me an error that the function can not be  
>>>>> found. Totally  cryptic to me. It is defined exactly like the  
>>>>> Print.js widget, do I  need to define my functions somewhere  
>>>>> else ?
>>>>>
>>>>> Also, if I have created a seperate widget that I want to use  
>>>>> just  like a new class in a conventional programming, like so.
>>>>>
>>>>> var myObject = new MyNewWidget();
>>>>>
>>>>> Do I need to call Fusion.Class or something ?
>>>>>
>>>>> Thanks
>>>>> Tomas
>>>>> _______________________________________________
>>>>> fusion-users mailing list
>>>>> fusion-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>>>>
>>>> __________________________________________
>>>>
>>>>    Paul SpencerTómas Guðmundsson <tomas at snertill.is>
>>>>    Chief Technology Officer
>>>>    DM Solutions Group Inc
>>>>    http://www.dmsolutions.ca/
>>>>
>>>> _______________________________________________
>>>> fusion-users mailing list
>>>> fusion-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>>>
>>>
>> _______________________________________________
>> fusion-users mailing list
>> fusion-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>
>
>
> -- 
> Alan Boudreault
> Mapgears
> http://www.mapgears.com
>
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://www.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
fusion-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fusion-users


More information about the fusion-users mailing list