AnsweredAssumed Answered

Web Appbuilder Communication Between Widgets

Question asked by ajmorris on Jan 14, 2015
Latest reply on Mar 19, 2015 by rscheitlin

Has anybody gotten publishData and fetchData to work? I see that all of the included widgets use regular Dojo topic publish/subscribe. So, I wonder if I'm making a mistake trying to use the wab publish and fetch methods.

 

I have a widget that publishes data. And, I have another widget ready to receive the data. On the receiving widget, in the startup method, I call fetchDataByName, and I get an error. Digging into the wab code, I see that the error occurs in this method of the BaseWidget:

    fetchDataByName: function(widgetName){
      //widgetId, the widget name that you want to read data. it is required.
      var widgets = this.widgetManager.getWidgetsByName(widgetName);


      array.forEach(widgets, function(widget){
        this.fetchData(widget.id);
      }, this);
    }

 

this.widgetManager is not set.

 

Does anybody have this working, and have any advice for me?

 

EDIT:

I was able to get this working using fetchData, rather than fetchDataByName. And, now I see that the widget has to be "open" to subscribe to the events. But, I'd like my widget to be hidden, until it receives data, at which time it should open.

 

SOLVED:

My problem was that I was trying to make my widget live in a panel. Instead, the widget can be out-of-panel, and I can use regular Dojo to hide the widget. The widget is technically "open", so it receives data. Once the widget receives data, I again use regular Dojo to show some HTML elements.

Outcomes