Opening a widget from another widget

2106
5
Jump to solution
07-18-2012 06:38 PM
JosephGrubbs
New Contributor III
I'm working on the building blocks for a custom widget/Popup window.  As a first step, I'm setting up to have a custom "Add to Favorites" button in the PopUp window fire a "RequestWidget" (a request for more information form) to open.  When I use the code recommendations posted in the FV 3.0 forum, I receive the following error message.  The code segments are below the error message.  Any suggestions?  Thanks so much in advance!

Joe


Error Message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.viewer.managers::WidgetManager/onRunWidget()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.esri.viewer::AppEvent$/dispatch()
at com.esri.viewer.customskins::PopUpRendererSkin/addToFavs_clickHandler()
at com.esri.viewer.customskins::PopUpRendererSkin/__addToFavsButton_click()

Imports:

import com.esri.viewer.AppEvent;
import com.esri.viewer.managers.WidgetManager;
import com.esri.viewer.ViewerContainer;


private function addToFavs_clickHandler(event:MouseEvent):void
{
AppEvent.dispatch(AppEvent.WIDGET_RUN,ViewerContainer.getInstance().widgetManager.getWidgetId("request"));
}
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Joe,

   So the Label (What appears as the widgets title) for your request widget is just "request"?... Also if you look at the error trace the error is actually coming from line 298 of your customskins\PopUpRendererSkin.mxml, what is on that line?

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Joe,

   So the Label (What appears as the widgets title) for your request widget is just "request"?... Also if you look at the error trace the error is actually coming from line 298 of your customskins\PopUpRendererSkin.mxml, what is on that line?
0 Kudos
JosephGrubbs
New Contributor III
Robert - The widget label actually is "RequestWidget" but using this was unsuccessful, also, so I attempted the id "request"...I'll change back to the label.

Here are lines 296-299

private function addToFavs_clickHandler(event:MouseEvent):void
{
AppEvent.dispatch(AppEvent.WIDGET_RUN,ViewerContainer.getInstance().widgetManager.getWidgetId("RequestWidget"));
}

And lines 316-321

<!--- @private -->
<s:Button id="addToFavsButton"
click="addToFavs_clickHandler(event)"
fontSize="12"
fontWeight="bold"
label="Add to Favorites"/>

Thanks so much for any assistance you can provide!

Joe
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Joe,

   I just tested this senario in Flex Viewer 2.5 and got my second popup button to launch the bookmarks widget just fine... Are you sure that the label of your other widget you are trying to bring up is "RequestWidget"? Remember Flex is a case sensitive language. So your widget tag looks like this in your main config.xml (Mainly the label I am concerned with).

        <widget label="RequestWidget" left="380" top="35"
            icon="assets/images/someimage.png"
            config="widgets/request/RequestWidget.xml"
            url="widgets/request/RequestWidget.swf"/>
0 Kudos
JosephGrubbs
New Contributor III
Robert - I will double check and make sure it's consistent.  Thanks so much!

Joe
0 Kudos
JosephGrubbs
New Contributor III
Robert - That did it!  I had used the file name instead of the label.  When I switched to the label, worked like a charm.  Again, I can't thank you enough for all your help!

Joe
0 Kudos