Select to view content in your preferred language

Communication between Widget and TOC Component

1283
6
07-21-2011 09:16 PM
NitinBele
Emerging Contributor
Hello,
How can I fetchSharedData() From TocItemRender.as ?
Any suggestions ?

Thanks ,
Lu.
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
Lu,

   In the past I have just traversed up the parent list until I got to the widget. Probably not the best way but it worked.
0 Kudos
NitinBele
Emerging Contributor
Thanks Robert !
Could you pls help me with some sample code for traversing to Widget from the component ?

Lu
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lu,

   Maybe you should tell me your workflow and or objective, the more I think about this the more complicated it is getting.
0 Kudos
NitinBele
Emerging Contributor
Lu,

   Maybe you should tell me your workflow and or objective, the more I think about this the more complicated it is getting.


Thanks Robert for your time !.
My workflow - i have a widget "W1" and I want to enable a specific Layer in the TOC (visibility on and off ) only after I get an input from "W1" say hit a "ok" button.

My workaround:
calling addsharedData() in "W1" and passing a boolean value in arraycollection.
fetching the boolean value in TocItemRender.as to on\off the specific Layer.
But i did not get fetchshareddata() funtion here.

please help me out if you could suggest me a better logic or a way to get to fetchSharedData()
TocItemRender.as .

Thanks Robert again for youe ultimate support.
Lu
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lu,

   So the only thing the fetchSharedData function is doing is dispatching an appEvent:

ViewerContainer.dispatchEvent(new AppEvent(AppEvent.DATA_FETCH_ALL));


Which in turn dispatches this event:

ViewerContainer.dispatchEvent(new AppEvent(AppEvent.DATA_SENT, dataTable));
in the DataManager.as.

So from W1 dispatch this event:
var data:Object =
            {
                key: key,
                collection: arrayCollection
            };
        ViewerContainer.dispatchEvent(new AppEvent(AppEvent.DATA_PUBLISH, data));


and in the toc add this listener:
ViewerContainer.addEventListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);


Then just a function that handles the event:

private function sharedDataUpdated(event:AppEvent):void
            {
                var data:Object = event.data;

                if (data.key == "your Key Name")
                {
                    //todo
                }
            }
0 Kudos
NitinBele
Emerging Contributor
Thanks Robert ! It worked really great.
I only need to change
from
ViewerContainer.addEventListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);


To
ViewerContainer.addEventListener(AppEvent.DATA_NEW_PUBLISHED, sharedDataUpdated);


Lu.
0 Kudos