5 Replies Latest reply on Nov 22, 2012 2:06 PM by dan19

    Retrieve the displayed content

    dan19

      Hi guys !

       

      I have an app with actions on all types of content (path="jive/actions/content/*").

      I'd like to retrieve the displayed content when the user click on the action app.

       

      Anyone knows where I should looking for ?

        • Re: Retrieve the content displayed
          dan19

          I found out that you can access to context data and retrieve the current content.

          Embedded context spec : Jive Apps Developer Community: App Selection and Embedded Context Spec

           

          My issue now is how to capture the context.

           

          I tried this but no value is fired :

          opensocial.data.getDataContext().registerListener('org.opensocial.ee.context', function(key) {

                  var data = opensocial.data.getDataContext().getDataSet(key);

                  console.log("Data", data);

          });

           

          I installed my app on the opensocial sandbox (http://sandbox.opensocial2.org:8080/collabapp/index.html ) as an "embedded experience" and the context data is properly returned.

            • Re: Retrieve the content displayed

              Dan A,

              Apologies, but I'm not quite following you... When you register the listener on the opensocial data context you should get this when the embedded experience opens. To get the context on the action contribution, that's a bit different because you actually register a callback. Would you be able to provide a bit more detail or an example??

                • Re: Retrieve the content displayed
                  dan19

                  Thanks Mark for your help.

                  All I want is retrieve the content displayed when the user click on the action link. Example : The user is reading a document and then click on the app action link.

                   

                  I register the listener only when the app is loaded.

                   

                  The complete code :

                  gadgets.util.registerOnLoadHandler(function() {

                    console.log("Gadget loaded !");

                    opensocial.data.getDataContext().registerListener('org.opensocial.ee.context', function(key) {

                         var data = opensocial.data.getDataContext().getDataSet(key);

                         console.log("Data", data);

                    });

                  });

                  This should fired context data or am I wrong ?

                    • Re: Retrieve the content displayed

                      There is a difference between an embedded experience and an action contribution. 

                      When you you use an embedded experience, you use the data context.

                       

                      If you are using an action contribution, then you would register a callback on the action id via the update action. Like this:

                        gadgets.actions.updateAction({

                              id:"com.jivesoftware.rte.dropper.html",

                              callback:loadContent

                          });