Select to view content in your preferred language

Running an MXML widget from another MXML widget

1309
14
12-09-2010 05:12 PM
BillBass
Deactivated User
I have an Identify widget and a Search widget in a single flex application. The process is that the user performs a search for point features using the search widget, which places a graphic layer on top of points that meet the search criteria. The user can then use the Identify widget to click on those points to get information.

Instead of the user having to look for the idenify tool in the menu, I would rather have a button in the Search widget window that the user can click on to open the Identify widget. I have seen some posts related to mxmls calling other mxmls, but I think they are performing more complex operations that what I am trying to do. I am just trying to setup an alterntive method to opening an existing widget.

I am attaching a zip file with the two MXML widget files for Identify and Search. The Identify MXML also has a configuraton xml file.

Thanks.
Tags (2)
0 Kudos
14 Replies
RobertScheitlin__GISP
MVP Emeritus
Bill,

   I am replying from by blackberry so I don't have the code in front of me so I can not give exacts be all you need to do is in your widget is add import statements for the SiteContainer and AppEvent

Something like:
import com.esri.viewer.AppEvent;
Import com.esri.viewer.SiteContainer
once again I and writing that code from memory.
0 Kudos
BillBass
Deactivated User
Thanks again. When I add the two import statements to the widget that is trying to call the identify tool, I get the following errors:
Definition com.esri.viewer:AppEvent could not be found.
Definition com.esri.viewer:SiteContainer could not be found.

So this must be something new to the 2.0 API, as I am still on 1.3. So I guess this isn't going to work.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Bill,

   Like I said I am doing this from memory, so you have to do some work on your end and search the code for the exact import statement. This is not something new for 2.x . I would look in the MapManager to find the exact import statements that you need to use as I obviously don't recall the exact text from memory.
0 Kudos
BillBass
Deactivated User
Robert,

Ok. I finally got it. The import statements for the 1.3 API are:
import com.esri.solutions.flexviewer.AppEvent;
import com.esri.solutions.flexviewer.SiteContainer;

So I added those to the MXML of the widget that contains the button to launch the identify tool, and the MXML for the button is:
<mx:Button id="idButton" label="Identify Features" click="SiteContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_MENU_CLICKED, false, false, 5))"/>

Thanks again and I appreciate your patience with someone new to Flex.

Bill
0 Kudos
RickyGonzalez
Deactivated User
Thanks for this snippet of code.  I was looking for the same functionality and it works great.
0 Kudos