Select to view content in your preferred language

Really close a widget Pt.  deux

1765
5
06-07-2011 06:39 PM
TylerWaring
Frequent Contributor
Greetings. This is a continuation of the origional post "Really Close a Widget" (http://forums.esri.com/thread.asp?c=158&f=2421&t=302669). Great stuff. However there are a few conceptual leaps required by the solution that I am not yet equiped to make.

The Solution:
public function closeWidget(id:Number, url:String):void
      {
       if (widgetTable.containsKey(id))
       {
        var widget0:IBaseWidget = widgetTable.find(id) as IBaseWidget;
        var wObj0:DisplayObject = widget0 as DisplayObject;
        widgetTable.remove(id);
        if(widgetBox.contains(wObj0))
         widgetBox.removeChild(wObj0);
       }
      
      
       if (moduleTable.containsKey(url))
       {
        var modInfo:IModuleInfo = moduleTable.find(url) as IModuleInfo;
        moduleTable.remove(url);
        modInfo.unload();
       } 
      }


Conceptual Leaps:
1. Where does this funciton belong.
2. How do you reference the widgetTable and moduleTable
3. How do you reference the widgetBox.

I realize that this is probably pretty complex to explain so any more hints to get me in the right direction will be greatly appreciated. ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_CHANGE_STATE, {id: this.widgetId, state:WidgetStates.WIDGET_CLOSED})); is not the appropriate way to close the widget if you wish to reloas the config file.

Thanks,
Tyler
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Tyler,

   If you put this function in the WidgetManager.mxml it will have the links it needs to the widgetTable, moduleTable, and widgetBox.
0 Kudos
TylerWaring
Frequent Contributor
Thanks Robert. Where would my projects be without your replies to my and other people's posts? I have loaded this function into the WidgetManager but widgetBox is not declared in the WidgetManager (Flex Viewer 2.2). Any suggestions?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tyler,

   I did not write that code for the new flex viewer and did not consider that the widgetbox is no longer in the WidgetManager.mxml but now the widgetContainer is a group in the WidgetContainer.mxml and is very different now.
0 Kudos
TylerWaring
Frequent Contributor
Is there a way to reference the widgetBox or is this line of logic a not the way to truely close a widget? I am having issues with my program because i can not really close a widget. Thanks. Tyler
0 Kudos
TylerWaring
Frequent Contributor
O.K.
I think that I may have crossed information from two separate versions of the Sample Flex Viewer or misdiagnosed/complicated the issue. There was a flaw in my logic and research that revealed itself last night. I now see that ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_CHANGE_STATE, {id: this.widgetId, state:WidgetStates.WIDGET_CLOSED})); does close the widget, at least to the extent I need for my program. I really had a different problem and some testing and research indicated the design I was implementing was flawed from the get go. A quick redesign has me back on track. Thanks for bearing with me.

Tyler
0 Kudos