FV 3.0 Widget Communication

1335
16
Jump to solution
08-04-2012 12:36 PM
JosephGrubbs
New Contributor III
I'm trying to get a custom addToFavs ("Add to Favorites") button in the PopUpRendererSkin to send data into the custom RequestWidget.  Any assistance would be greatly appreciated!

Joe

CODE SEGMENTS

Here's the code from the PopUpRendererSkin.  The code to initialize the Request widget is working but I'm getting a "Call to a possibly undefined method" message on the "addSharedData" line. 

private function addToFavs_clickHandler(event:MouseEvent):void
{
[INDENT]var msArr:ArrayCollection = new ArrayCollection();
  msArr.addItem("Board Name");
  msArr.addItem("Location");
  msArr.addItem("Street Side");
  msArr.addItem("Facing");
  addSharedData("MiniSearch_Search", msArr)
  //The code to initialize the Request widget if needed
  AppEvent.dispatch(AppEvent.WIDGET_RUN,ViewerContainer.getInstance().widgetManager.getWidgetId("Request Board Information"));[/INDENT]
}


Here's the code from the Request widget.  I'm not getting any errors on this code but of course cannot test it until I'm able to send the data from the PopUpRendererSkin.


protected function PopUpRendererSkin_initializeHandler(event:FlexEvent):void
{
[INDENT]AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedData);
AppEvent.addListener(AppEvent.DATA_SENT, sharedData2);
fetchSharedData();[/INDENT]
}
  
private function sharedData(event:AppEvent):void
{
[INDENT]if (data.key == "MiniSearch_Search")
{
if (data.collection[0]){
com.esri.viewer.customskins.PopUpRendererSkin(data.collection[0]);[/INDENT]
}
}
}
  
private function sharedData2(event:AppEvent):void
{
[INDENT]var dataTable:Hashtable = event.data as Hashtable;
if (dataTable.containsKey("MiniSearch_Search"))
{
var recAC:ArrayCollection = dataTable.find("MiniSearch_Search") as ArrayCollection;
if (recAC[0]){
com.esri.viewer.customskins.PopUpRendererSkin(recAC[0]);[/INDENT]
}
}
}
Tags (2)
0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Emeritus
Joe,

   Just to double chack what version of the Flex Viewer are you using?
0 Kudos
JosephGrubbs
New Contributor III
The pre-release of 3.0.  We had so much custom code, the owner decided that, rather than have me complete the migration to the final release now, we would wait and do it after the site is live.

Thank you!

Joe
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Joe,

   Hmm... Can't say I agree with that decision even slightly. There are so many things that got fixed from pre release to the final... Pre-Releases are NEVER intended to be used on production sites. Anyway I can not guarantee that the provided code is pre-release compatable. But I can say with some changes to library names I did test this in Flex Viewer 3.0 Final and I had the code working as far as transferring data from the popup to the widget and displaying an alert window with the data.
0 Kudos
JosephGrubbs
New Contributor III
Robert - Understood and agreed.  I'll work with the code you provided and see if I can get it to work in our current build. Thanks, again, for all your help!

Joe
0 Kudos
JosephGrubbs
New Contributor III
Robert - I've gotten it to work, at least on the first click. When I replaced the Request widget mxml file with the one you sent I also had to re-specify the Flex Module for the Request widget.  When I did that, the message appeared on the first "Add to Favorites" click event.

Now, however, it's not continuing to work with subsequent clicks.  In other words, the shared data message only appears when the Request widget has been opened with the first "Add to Favorites" click.  Is there a separate var I need to add to the addToFavs_clickHandler function to have the shared data message appear on subsequent clicks/after the Request widget has been opened?

This is looking very good!

Thank you!

Joe
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Joe,

   Update this:

            private function sharedDataUpdated(event:AppEvent):void             {                 if (event.data.key == "Board_Data")                 {                     if (event.data.collection[0]){                         //mailme();                         add2favs(event.data.collection[0]);                     }                 }             }
0 Kudos
JosephGrubbs
New Contributor III
Robert - That's got it.  The shared data message works now with the initial click (along with opening the Request widget), subsequent clicks, and after closing/re-opening the Request widget.  Cannot thank you enough!

My next/final step will be to pass the board information from the alert into the actual Request widget form and, when the user clicks the "Submit Request" button, the email message.  I'm working on that now.

Again, thank you so much!

Joe
0 Kudos