You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@shindig.apache.org by Wade Girard <Wa...@Calabrio.com> on 2014/02/12 20:16:34 UTC

Noob Help

I am trying to implement a container running under Shindig.

I am having difficulty getting the rpc (Gadget->Contianer) communication working.

Here is my simple gadget:

<Module>

  <ModulePrefs title="Hello World">

    <Require feature="rpc" />

  </ModulePrefs>

  <UserPref name="myName" display_name="Name" default_value="Wade" />

  <Content type="html">

<![CDATA[

<script type="text/javascript">

gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there! Pre-onload message sent successfully.');

</script>

<div id="widgetNode">Hello World</div>

]]>

  </Content>

</Module>

Here is what I have done on the server (adapted)

var id = "gadget_" + (this._static.id++);

gadgets.rpc.register("initial_gadget_message", _messageHandler));

var parent = window.location.origin; // also tried window.location.href

iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent + "&rpctoken=12345";

iFrameNode.id = id;

gadgets.rpc.setupReceiver(id);

The container is at port 80, the gadget is at port 8080, on the same server (localhost)
The gadget loads in the container, but most of the time produces this message, sometimes, vary rarely, it will not produce the message.

No relay set (used as window.postMessage targetOrigin), cannot send cross-domain message

Any help is appreciated, thanks
--
Wade Girard | Principal Software Engineer
Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
Phone: 763.795.7798

Re: Noob Help

Posted by Wade Girard <Wa...@Calabrio.com>.
Thank you for this, this change made it work.

Thanks
-- 
Wade Girard | Principal Software Engineer

Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
Phone: 763.795.7798




On 2/13/14, 10:40 AM, "Ryan Baxter" <rb...@apache.org> wrote:

>Thanks, this helped alot.  The problem is how you are rendering the
>gadget, you are doing more work than you have to :)  For this simple
>sample there is no need to preload the gadget.  So you can removed the
>addGadgetHandler function and replace addGadget with this code.
>
>function addGadget() {
>  var parent = window.location.origin;
>  var el = document.getElementById("gadgetContainer");
>  var site = container.newGadgetSite(el)
>  var params = {};
>  params[osapi.container.RenderParam.WIDTH] = '100%';
>  container.navigateGadget(site, gadgetUrl, {}, params);
>  console.log("inside add gadget handler");
>}
>
>Calling navigateGadget helps to setup the rpc functionality.  I tested
>this in FF and Chrome and it seems to work.  Hope this helps!
>
>On Thu, Feb 13, 2014 at 10:41 AM, Wade Girard <Wa...@calabrio.com>
>wrote:
>> Okay, sorry for the delay, took me a little time to put this together
>>
>> Here is the container html
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>>         <style>
>>                 .gadget {
>>                         width: 500;
>>                         height: 500;
>>                         border: 1px solid silver;
>>                 }
>>         </style>
>>         <script type="text/javascript"
>> 
>>src="../../../gadgets/js/container:open-views:opensearch:rpc:xmlutil:pubs
>>ub
>> -2.js?c=1&debug=1&container=default"></script>
>>         <script type="text/javascript">
>>                 var container, gadgetUrl =
>> "http://localhost/cwfo/gadgets/HelloWorld.xml";
>>
>>                 function addGadget() {
>>                         console.log("preloading gadget:" + gadgetUrl);
>>                         container.preloadGadget(gadgetUrl,
>>addGadgetHandler);
>>                 }
>>
>>                 function addGadgetHandler(resp) {
>>                         var gSpec = resp[gadgetUrl];
>>                         if (typeof gSpec !== 'undefined') {
>>                                 var parent = window.location.origin;
>>                                 var container =
>>document.getElementById("gadgetContainer");
>>                                 iFrame = "<iframe class='gadget' src='"
>>+ gSpec.iframeUrls["default"]
>> + "#parent=" + parent + "&rpctoken=1234" + "'>";
>>                                 container.innerHTML = iFrame;
>>                                 console.log("inside add gadget
>>handler");
>>                         } else {
>>                                 alert("unable to add gadget");
>>                         }
>>                 }
>>
>>                 function msgHandler(msg) {
>>                         console.log(msg);
>>                 }
>>
>>                 var urlBase = location.href.substr(0,
>>location.href.indexOf('/cwfo'));
>>                 var contextRoot =
>>urlBase.substr(urlBase.indexOf(location.host) +
>> location.host.length);
>>
>>                 var testConfig = {};
>>                 testConfig[osapi.container.ServiceConfig.API_PATH] =
>>contextRoot +
>> '/rpc';
>>                 
>>testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>>                 
>>testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
>> function(callback) {
>>                         gadgets.log('Updating container security
>>token.');
>>                 
>>callback('john.doe:john.doe:appid:cont:url:0:default', 0);
>>                 };
>>                 container = new osapi.container.Container(testConfig);
>>                 container.rpcRegister("initial_gadget_message",
>>msgHandler);
>>         </script>
>> </head>
>> <body>
>>         <div>
>>                 <button onclick="addGadget()">Click To Add</button>
>>                 <div id="gadgetContainer"></div>
>>         </div>
>> </body>
>> </html>
>>
>>
>> I am using version 2.5 update 1
>> --
>> Wade Girard | Principal Software Engineer
>>
>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>> Phone: 763.795.7798
>>
>>
>>
>>
>> On 2/12/14, 3:24 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>>
>>>Wade can you provide a sample container html file so I can try it
>>>locally?  What version of Shindig are you using?
>>>
>>>On Wed, Feb 12, 2014 at 3:50 PM, Wade Girard <Wa...@calabrio.com>
>>>wrote:
>>>> Hi Ryan,
>>>>         Thank you for your suggestions. I changed the gadget to this
>>>> <Module>
>>>>   <ModulePrefs title="Hello World">
>>>>     <Require feature="rpc" />
>>>>   </ModulePrefs>
>>>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>>>   <Content type="html">
>>>>         <![CDATA[
>>>>         <script type="text/javascript">
>>>>                 function init() {
>>>>                         gadgets.rpc.call(null,
>>>>'initial_gadget_message', null, 'Hello there!
>>>> Pre-onload message sent successfully.');
>>>>                 }
>>>>                 gadgets.util.registerOnLoadHandler(init);
>>>>         </script>
>>>>         <div id="widgetNode">Hello World</div>
>>>>         ]]>
>>>>   </Content>
>>>> </Module>
>>>>
>>>>
>>>> And Removed the code that did the gadgets.rpc.register and
>>>> gadgets.rpc.setupReceiver and added the code to the container. Here is
>>>> what it looks like (added the full config, in case I am missing
>>>>something
>>>> there)
>>>>
>>>> var testConfig = {};
>>>>
>>>>testConfig[osapi.container.ServiceConfig.API_PATH] =
>>>> 'http://localhost/rpc';
>>>>
>>>>testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>>>>
>>>>testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
>>>> function(callback) {
>>>>                                 gadgets.log('Updating container
>>>>security token.');
>>>>
>>>>callback('john.doe:john.doe:appid:cont:url:0:default', 10);
>>>>                         };
>>>> this._container = new osapi.container.Container(testConfig);
>>>>
>>>>this._container.rpcRegister("initial_gadget_message",
>>>> _setTitleHandler));
>>>>
>>>>
>>>>
>>>> Unfortunately I am still getting the same message in the firebug
>>>>console
>>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>>> cross-domain message
>>>>
>>>>
>>>> Thanks for all your help.
>>>> --
>>>> Wade Girard | Principal Software Engineer
>>>>
>>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>>> Phone: 763.795.7798
>>>>
>>>>
>>>>
>>>>
>>>> On 2/12/14, 2:31 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>>>>
>>>>>Hi Wade,
>>>>>
>>>>>A couple of comments.
>>>>>
>>>>>1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
>>>>>function passed to gadgets.util.registerOnLoadHandler to make sure the
>>>>>gadget is completely initialized before making that rpc call.
>>>>>2.)  In your container I would suggest you use the container feature.
>>>>>It takes care of some of the nasty stuff with regards to registering
>>>>>RPC callback functions.  All you then have to do is call
>>>>>container.rpcRegister('initial_gadget_message', _messageHandler)
>>>>>
>>>>>On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard
>>>>><Wa...@calabrio.com>
>>>>>wrote:
>>>>>> I am trying to implement a container running under Shindig.
>>>>>>
>>>>>> I am having difficulty getting the rpc (Gadget->Contianer)
>>>>>>communication working.
>>>>>>
>>>>>> Here is my simple gadget:
>>>>>>
>>>>>> <Module>
>>>>>>
>>>>>>   <ModulePrefs title="Hello World">
>>>>>>
>>>>>>     <Require feature="rpc" />
>>>>>>
>>>>>>   </ModulePrefs>
>>>>>>
>>>>>>   <UserPref name="myName" display_name="Name" default_value="Wade"
>>>>>>/>
>>>>>>
>>>>>>   <Content type="html">
>>>>>>
>>>>>> <![CDATA[
>>>>>>
>>>>>> <script type="text/javascript">
>>>>>>
>>>>>> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
>>>>>>Pre-onload message sent successfully.');
>>>>>>
>>>>>> </script>
>>>>>>
>>>>>> <div id="widgetNode">Hello World</div>
>>>>>>
>>>>>> ]]>
>>>>>>
>>>>>>   </Content>
>>>>>>
>>>>>> </Module>
>>>>>>
>>>>>> Here is what I have done on the server (adapted)
>>>>>>
>>>>>> var id = "gadget_" + (this._static.id++);
>>>>>>
>>>>>> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>>>>>>
>>>>>> var parent = window.location.origin; // also tried
>>>>>>window.location.href
>>>>>>
>>>>>> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent +
>>>>>>"&rpctoken=12345";
>>>>>>
>>>>>> iFrameNode.id = id;
>>>>>>
>>>>>> gadgets.rpc.setupReceiver(id);
>>>>>>
>>>>>> The container is at port 80, the gadget is at port 8080, on the same
>>>>>>server (localhost)
>>>>>> The gadget loads in the container, but most of the time produces
>>>>>>this
>>>>>>message, sometimes, vary rarely, it will not produce the message.
>>>>>>
>>>>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>>>>>cross-domain message
>>>>>>
>>>>>> Any help is appreciated, thanks
>>>>>> --
>>>>>> Wade Girard | Principal Software Engineer
>>>>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>>>>> Phone: 763.795.7798
>>>>
>>


Re: Noob Help

Posted by Ryan Baxter <rb...@apache.org>.
Thanks, this helped alot.  The problem is how you are rendering the
gadget, you are doing more work than you have to :)  For this simple
sample there is no need to preload the gadget.  So you can removed the
addGadgetHandler function and replace addGadget with this code.

function addGadget() {
  var parent = window.location.origin;
  var el = document.getElementById("gadgetContainer");
  var site = container.newGadgetSite(el)
  var params = {};
  params[osapi.container.RenderParam.WIDTH] = '100%';
  container.navigateGadget(site, gadgetUrl, {}, params);
  console.log("inside add gadget handler");
}

Calling navigateGadget helps to setup the rpc functionality.  I tested
this in FF and Chrome and it seems to work.  Hope this helps!

On Thu, Feb 13, 2014 at 10:41 AM, Wade Girard <Wa...@calabrio.com> wrote:
> Okay, sorry for the delay, took me a little time to put this together
>
> Here is the container html
>
> <!DOCTYPE html>
> <html>
> <head>
>         <style>
>                 .gadget {
>                         width: 500;
>                         height: 500;
>                         border: 1px solid silver;
>                 }
>         </style>
>         <script type="text/javascript"
> src="../../../gadgets/js/container:open-views:opensearch:rpc:xmlutil:pubsub
> -2.js?c=1&debug=1&container=default"></script>
>         <script type="text/javascript">
>                 var container, gadgetUrl =
> "http://localhost/cwfo/gadgets/HelloWorld.xml";
>
>                 function addGadget() {
>                         console.log("preloading gadget:" + gadgetUrl);
>                         container.preloadGadget(gadgetUrl, addGadgetHandler);
>                 }
>
>                 function addGadgetHandler(resp) {
>                         var gSpec = resp[gadgetUrl];
>                         if (typeof gSpec !== 'undefined') {
>                                 var parent = window.location.origin;
>                                 var container = document.getElementById("gadgetContainer");
>                                 iFrame = "<iframe class='gadget' src='" + gSpec.iframeUrls["default"]
> + "#parent=" + parent + "&rpctoken=1234" + "'>";
>                                 container.innerHTML = iFrame;
>                                 console.log("inside add gadget handler");
>                         } else {
>                                 alert("unable to add gadget");
>                         }
>                 }
>
>                 function msgHandler(msg) {
>                         console.log(msg);
>                 }
>
>                 var urlBase = location.href.substr(0, location.href.indexOf('/cwfo'));
>                 var contextRoot = urlBase.substr(urlBase.indexOf(location.host) +
> location.host.length);
>
>                 var testConfig = {};
>                 testConfig[osapi.container.ServiceConfig.API_PATH] = contextRoot +
> '/rpc';
>                 testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>                 testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
> function(callback) {
>                         gadgets.log('Updating container security token.');
>                         callback('john.doe:john.doe:appid:cont:url:0:default', 0);
>                 };
>                 container = new osapi.container.Container(testConfig);
>                 container.rpcRegister("initial_gadget_message", msgHandler);
>         </script>
> </head>
> <body>
>         <div>
>                 <button onclick="addGadget()">Click To Add</button>
>                 <div id="gadgetContainer"></div>
>         </div>
> </body>
> </html>
>
>
> I am using version 2.5 update 1
> --
> Wade Girard | Principal Software Engineer
>
> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
> Phone: 763.795.7798
>
>
>
>
> On 2/12/14, 3:24 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>
>>Wade can you provide a sample container html file so I can try it
>>locally?  What version of Shindig are you using?
>>
>>On Wed, Feb 12, 2014 at 3:50 PM, Wade Girard <Wa...@calabrio.com>
>>wrote:
>>> Hi Ryan,
>>>         Thank you for your suggestions. I changed the gadget to this
>>> <Module>
>>>   <ModulePrefs title="Hello World">
>>>     <Require feature="rpc" />
>>>   </ModulePrefs>
>>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>>   <Content type="html">
>>>         <![CDATA[
>>>         <script type="text/javascript">
>>>                 function init() {
>>>                         gadgets.rpc.call(null,
>>>'initial_gadget_message', null, 'Hello there!
>>> Pre-onload message sent successfully.');
>>>                 }
>>>                 gadgets.util.registerOnLoadHandler(init);
>>>         </script>
>>>         <div id="widgetNode">Hello World</div>
>>>         ]]>
>>>   </Content>
>>> </Module>
>>>
>>>
>>> And Removed the code that did the gadgets.rpc.register and
>>> gadgets.rpc.setupReceiver and added the code to the container. Here is
>>> what it looks like (added the full config, in case I am missing
>>>something
>>> there)
>>>
>>> var testConfig = {};
>>>
>>>testConfig[osapi.container.ServiceConfig.API_PATH] =
>>> 'http://localhost/rpc';
>>>
>>>testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>>>
>>>testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
>>> function(callback) {
>>>                                 gadgets.log('Updating container
>>>security token.');
>>>
>>>callback('john.doe:john.doe:appid:cont:url:0:default', 10);
>>>                         };
>>> this._container = new osapi.container.Container(testConfig);
>>>
>>>this._container.rpcRegister("initial_gadget_message",
>>> _setTitleHandler));
>>>
>>>
>>>
>>> Unfortunately I am still getting the same message in the firebug console
>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>> cross-domain message
>>>
>>>
>>> Thanks for all your help.
>>> --
>>> Wade Girard | Principal Software Engineer
>>>
>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>> Phone: 763.795.7798
>>>
>>>
>>>
>>>
>>> On 2/12/14, 2:31 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>>>
>>>>Hi Wade,
>>>>
>>>>A couple of comments.
>>>>
>>>>1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
>>>>function passed to gadgets.util.registerOnLoadHandler to make sure the
>>>>gadget is completely initialized before making that rpc call.
>>>>2.)  In your container I would suggest you use the container feature.
>>>>It takes care of some of the nasty stuff with regards to registering
>>>>RPC callback functions.  All you then have to do is call
>>>>container.rpcRegister('initial_gadget_message', _messageHandler)
>>>>
>>>>On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard <Wa...@calabrio.com>
>>>>wrote:
>>>>> I am trying to implement a container running under Shindig.
>>>>>
>>>>> I am having difficulty getting the rpc (Gadget->Contianer)
>>>>>communication working.
>>>>>
>>>>> Here is my simple gadget:
>>>>>
>>>>> <Module>
>>>>>
>>>>>   <ModulePrefs title="Hello World">
>>>>>
>>>>>     <Require feature="rpc" />
>>>>>
>>>>>   </ModulePrefs>
>>>>>
>>>>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>>>>
>>>>>   <Content type="html">
>>>>>
>>>>> <![CDATA[
>>>>>
>>>>> <script type="text/javascript">
>>>>>
>>>>> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
>>>>>Pre-onload message sent successfully.');
>>>>>
>>>>> </script>
>>>>>
>>>>> <div id="widgetNode">Hello World</div>
>>>>>
>>>>> ]]>
>>>>>
>>>>>   </Content>
>>>>>
>>>>> </Module>
>>>>>
>>>>> Here is what I have done on the server (adapted)
>>>>>
>>>>> var id = "gadget_" + (this._static.id++);
>>>>>
>>>>> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>>>>>
>>>>> var parent = window.location.origin; // also tried
>>>>>window.location.href
>>>>>
>>>>> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent +
>>>>>"&rpctoken=12345";
>>>>>
>>>>> iFrameNode.id = id;
>>>>>
>>>>> gadgets.rpc.setupReceiver(id);
>>>>>
>>>>> The container is at port 80, the gadget is at port 8080, on the same
>>>>>server (localhost)
>>>>> The gadget loads in the container, but most of the time produces this
>>>>>message, sometimes, vary rarely, it will not produce the message.
>>>>>
>>>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>>>>cross-domain message
>>>>>
>>>>> Any help is appreciated, thanks
>>>>> --
>>>>> Wade Girard | Principal Software Engineer
>>>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>>>> Phone: 763.795.7798
>>>
>

Re: Noob Help

Posted by Wade Girard <Wa...@Calabrio.com>.
Okay, sorry for the delay, took me a little time to put this together

Here is the container html

<!DOCTYPE html>
<html>
<head>
	<style>
		.gadget {
			width: 500;
			height: 500;
			border: 1px solid silver;
		}
	</style>
	<script type="text/javascript"
src="../../../gadgets/js/container:open-views:opensearch:rpc:xmlutil:pubsub
-2.js?c=1&debug=1&container=default"></script>
	<script type="text/javascript">
		var container, gadgetUrl =
"http://localhost/cwfo/gadgets/HelloWorld.xml";
		
		function addGadget() {
			console.log("preloading gadget:" + gadgetUrl);
			container.preloadGadget(gadgetUrl, addGadgetHandler);
		}
		
		function addGadgetHandler(resp) {
			var gSpec = resp[gadgetUrl];
			if (typeof gSpec !== 'undefined') {
				var parent = window.location.origin;
				var container = document.getElementById("gadgetContainer");
				iFrame = "<iframe class='gadget' src='" + gSpec.iframeUrls["default"]
+ "#parent=" + parent + "&rpctoken=1234" + "'>";
				container.innerHTML = iFrame;
				console.log("inside add gadget handler");
			} else {
				alert("unable to add gadget");
			}
		}
		
		function msgHandler(msg) {
			console.log(msg);
		}
		
		var urlBase = location.href.substr(0, location.href.indexOf('/cwfo'));
		var contextRoot = urlBase.substr(urlBase.indexOf(location.host) +
location.host.length);
		
		var testConfig = {};
		testConfig[osapi.container.ServiceConfig.API_PATH] = contextRoot +
'/rpc';
		testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
		testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
function(callback) {
			gadgets.log('Updating container security token.');
			callback('john.doe:john.doe:appid:cont:url:0:default', 0);
		};
		container = new osapi.container.Container(testConfig);
		container.rpcRegister("initial_gadget_message", msgHandler);
	</script>
</head>
<body>
	<div>
		<button onclick="addGadget()">Click To Add</button>
		<div id="gadgetContainer"></div>
	</div>
</body>
</html>


I am using version 2.5 update 1
-- 
Wade Girard | Principal Software Engineer

Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
Phone: 763.795.7798




On 2/12/14, 3:24 PM, "Ryan Baxter" <rb...@apache.org> wrote:

>Wade can you provide a sample container html file so I can try it
>locally?  What version of Shindig are you using?
>
>On Wed, Feb 12, 2014 at 3:50 PM, Wade Girard <Wa...@calabrio.com>
>wrote:
>> Hi Ryan,
>>         Thank you for your suggestions. I changed the gadget to this
>> <Module>
>>   <ModulePrefs title="Hello World">
>>     <Require feature="rpc" />
>>   </ModulePrefs>
>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>   <Content type="html">
>>         <![CDATA[
>>         <script type="text/javascript">
>>                 function init() {
>>                         gadgets.rpc.call(null,
>>'initial_gadget_message', null, 'Hello there!
>> Pre-onload message sent successfully.');
>>                 }
>>                 gadgets.util.registerOnLoadHandler(init);
>>         </script>
>>         <div id="widgetNode">Hello World</div>
>>         ]]>
>>   </Content>
>> </Module>
>>
>>
>> And Removed the code that did the gadgets.rpc.register and
>> gadgets.rpc.setupReceiver and added the code to the container. Here is
>> what it looks like (added the full config, in case I am missing
>>something
>> there)
>>
>> var testConfig = {};
>>                 
>>testConfig[osapi.container.ServiceConfig.API_PATH] =
>> 'http://localhost/rpc';
>>                 
>>testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>>                 
>>testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
>> function(callback) {
>>                                 gadgets.log('Updating container
>>security token.');
>>                 
>>callback('john.doe:john.doe:appid:cont:url:0:default', 10);
>>                         };
>> this._container = new osapi.container.Container(testConfig);
>>                 
>>this._container.rpcRegister("initial_gadget_message",
>> _setTitleHandler));
>>
>>
>>
>> Unfortunately I am still getting the same message in the firebug console
>> No relay set (used as window.postMessage targetOrigin), cannot send
>> cross-domain message
>>
>>
>> Thanks for all your help.
>> --
>> Wade Girard | Principal Software Engineer
>>
>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>> Phone: 763.795.7798
>>
>>
>>
>>
>> On 2/12/14, 2:31 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>>
>>>Hi Wade,
>>>
>>>A couple of comments.
>>>
>>>1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
>>>function passed to gadgets.util.registerOnLoadHandler to make sure the
>>>gadget is completely initialized before making that rpc call.
>>>2.)  In your container I would suggest you use the container feature.
>>>It takes care of some of the nasty stuff with regards to registering
>>>RPC callback functions.  All you then have to do is call
>>>container.rpcRegister('initial_gadget_message', _messageHandler)
>>>
>>>On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard <Wa...@calabrio.com>
>>>wrote:
>>>> I am trying to implement a container running under Shindig.
>>>>
>>>> I am having difficulty getting the rpc (Gadget->Contianer)
>>>>communication working.
>>>>
>>>> Here is my simple gadget:
>>>>
>>>> <Module>
>>>>
>>>>   <ModulePrefs title="Hello World">
>>>>
>>>>     <Require feature="rpc" />
>>>>
>>>>   </ModulePrefs>
>>>>
>>>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>>>
>>>>   <Content type="html">
>>>>
>>>> <![CDATA[
>>>>
>>>> <script type="text/javascript">
>>>>
>>>> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
>>>>Pre-onload message sent successfully.');
>>>>
>>>> </script>
>>>>
>>>> <div id="widgetNode">Hello World</div>
>>>>
>>>> ]]>
>>>>
>>>>   </Content>
>>>>
>>>> </Module>
>>>>
>>>> Here is what I have done on the server (adapted)
>>>>
>>>> var id = "gadget_" + (this._static.id++);
>>>>
>>>> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>>>>
>>>> var parent = window.location.origin; // also tried
>>>>window.location.href
>>>>
>>>> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent +
>>>>"&rpctoken=12345";
>>>>
>>>> iFrameNode.id = id;
>>>>
>>>> gadgets.rpc.setupReceiver(id);
>>>>
>>>> The container is at port 80, the gadget is at port 8080, on the same
>>>>server (localhost)
>>>> The gadget loads in the container, but most of the time produces this
>>>>message, sometimes, vary rarely, it will not produce the message.
>>>>
>>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>>>cross-domain message
>>>>
>>>> Any help is appreciated, thanks
>>>> --
>>>> Wade Girard | Principal Software Engineer
>>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>>> Phone: 763.795.7798
>>


Re: Noob Help

Posted by Ryan Baxter <rb...@apache.org>.
Wade can you provide a sample container html file so I can try it
locally?  What version of Shindig are you using?

On Wed, Feb 12, 2014 at 3:50 PM, Wade Girard <Wa...@calabrio.com> wrote:
> Hi Ryan,
>         Thank you for your suggestions. I changed the gadget to this
> <Module>
>   <ModulePrefs title="Hello World">
>     <Require feature="rpc" />
>   </ModulePrefs>
>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>   <Content type="html">
>         <![CDATA[
>         <script type="text/javascript">
>                 function init() {
>                         gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
> Pre-onload message sent successfully.');
>                 }
>                 gadgets.util.registerOnLoadHandler(init);
>         </script>
>         <div id="widgetNode">Hello World</div>
>         ]]>
>   </Content>
> </Module>
>
>
> And Removed the code that did the gadgets.rpc.register and
> gadgets.rpc.setupReceiver and added the code to the container. Here is
> what it looks like (added the full config, in case I am missing something
> there)
>
> var testConfig = {};
>                         testConfig[osapi.container.ServiceConfig.API_PATH] =
> 'http://localhost/rpc';
>                         testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
>                         testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
> function(callback) {
>                                 gadgets.log('Updating container security token.');
>                                 callback('john.doe:john.doe:appid:cont:url:0:default', 10);
>                         };
> this._container = new osapi.container.Container(testConfig);
>                         this._container.rpcRegister("initial_gadget_message",
> _setTitleHandler));
>
>
>
> Unfortunately I am still getting the same message in the firebug console
> No relay set (used as window.postMessage targetOrigin), cannot send
> cross-domain message
>
>
> Thanks for all your help.
> --
> Wade Girard | Principal Software Engineer
>
> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
> Phone: 763.795.7798
>
>
>
>
> On 2/12/14, 2:31 PM, "Ryan Baxter" <rb...@apache.org> wrote:
>
>>Hi Wade,
>>
>>A couple of comments.
>>
>>1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
>>function passed to gadgets.util.registerOnLoadHandler to make sure the
>>gadget is completely initialized before making that rpc call.
>>2.)  In your container I would suggest you use the container feature.
>>It takes care of some of the nasty stuff with regards to registering
>>RPC callback functions.  All you then have to do is call
>>container.rpcRegister('initial_gadget_message', _messageHandler)
>>
>>On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard <Wa...@calabrio.com>
>>wrote:
>>> I am trying to implement a container running under Shindig.
>>>
>>> I am having difficulty getting the rpc (Gadget->Contianer)
>>>communication working.
>>>
>>> Here is my simple gadget:
>>>
>>> <Module>
>>>
>>>   <ModulePrefs title="Hello World">
>>>
>>>     <Require feature="rpc" />
>>>
>>>   </ModulePrefs>
>>>
>>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>>
>>>   <Content type="html">
>>>
>>> <![CDATA[
>>>
>>> <script type="text/javascript">
>>>
>>> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
>>>Pre-onload message sent successfully.');
>>>
>>> </script>
>>>
>>> <div id="widgetNode">Hello World</div>
>>>
>>> ]]>
>>>
>>>   </Content>
>>>
>>> </Module>
>>>
>>> Here is what I have done on the server (adapted)
>>>
>>> var id = "gadget_" + (this._static.id++);
>>>
>>> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>>>
>>> var parent = window.location.origin; // also tried window.location.href
>>>
>>> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent +
>>>"&rpctoken=12345";
>>>
>>> iFrameNode.id = id;
>>>
>>> gadgets.rpc.setupReceiver(id);
>>>
>>> The container is at port 80, the gadget is at port 8080, on the same
>>>server (localhost)
>>> The gadget loads in the container, but most of the time produces this
>>>message, sometimes, vary rarely, it will not produce the message.
>>>
>>> No relay set (used as window.postMessage targetOrigin), cannot send
>>>cross-domain message
>>>
>>> Any help is appreciated, thanks
>>> --
>>> Wade Girard | Principal Software Engineer
>>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>>> Phone: 763.795.7798
>

Re: Noob Help

Posted by Wade Girard <Wa...@Calabrio.com>.
Hi Ryan,
	Thank you for your suggestions. I changed the gadget to this
<Module>
  <ModulePrefs title="Hello World">
    <Require feature="rpc" />
  </ModulePrefs>
  <UserPref name="myName" display_name="Name" default_value="Wade" />
  <Content type="html">
	<![CDATA[
	<script type="text/javascript">
		function init() {
			gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
Pre-onload message sent successfully.');
		}
		gadgets.util.registerOnLoadHandler(init);
	</script>
	<div id="widgetNode">Hello World</div>
	]]>
  </Content>
</Module>


And Removed the code that did the gadgets.rpc.register and
gadgets.rpc.setupReceiver and added the code to the container. Here is
what it looks like (added the full config, in case I am missing something
there)

var testConfig = {};
			testConfig[osapi.container.ServiceConfig.API_PATH] =
'http://localhost/rpc';
			testConfig[osapi.container.ContainerConfig.RENDER_DEBUG] = '1';
			testConfig[osapi.container.ContainerConfig.GET_CONTAINER_TOKEN] =
function(callback) {
				gadgets.log('Updating container security token.');
				callback('john.doe:john.doe:appid:cont:url:0:default', 10);
			};
this._container = new osapi.container.Container(testConfig);
			this._container.rpcRegister("initial_gadget_message",
_setTitleHandler));



Unfortunately I am still getting the same message in the firebug console
No relay set (used as window.postMessage targetOrigin), cannot send
cross-domain message


Thanks for all your help.
-- 
Wade Girard | Principal Software Engineer

Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
Phone: 763.795.7798




On 2/12/14, 2:31 PM, "Ryan Baxter" <rb...@apache.org> wrote:

>Hi Wade,
>
>A couple of comments.
>
>1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
>function passed to gadgets.util.registerOnLoadHandler to make sure the
>gadget is completely initialized before making that rpc call.
>2.)  In your container I would suggest you use the container feature.
>It takes care of some of the nasty stuff with regards to registering
>RPC callback functions.  All you then have to do is call
>container.rpcRegister('initial_gadget_message', _messageHandler)
>
>On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard <Wa...@calabrio.com>
>wrote:
>> I am trying to implement a container running under Shindig.
>>
>> I am having difficulty getting the rpc (Gadget->Contianer)
>>communication working.
>>
>> Here is my simple gadget:
>>
>> <Module>
>>
>>   <ModulePrefs title="Hello World">
>>
>>     <Require feature="rpc" />
>>
>>   </ModulePrefs>
>>
>>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>>
>>   <Content type="html">
>>
>> <![CDATA[
>>
>> <script type="text/javascript">
>>
>> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there!
>>Pre-onload message sent successfully.');
>>
>> </script>
>>
>> <div id="widgetNode">Hello World</div>
>>
>> ]]>
>>
>>   </Content>
>>
>> </Module>
>>
>> Here is what I have done on the server (adapted)
>>
>> var id = "gadget_" + (this._static.id++);
>>
>> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>>
>> var parent = window.location.origin; // also tried window.location.href
>>
>> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent +
>>"&rpctoken=12345";
>>
>> iFrameNode.id = id;
>>
>> gadgets.rpc.setupReceiver(id);
>>
>> The container is at port 80, the gadget is at port 8080, on the same
>>server (localhost)
>> The gadget loads in the container, but most of the time produces this
>>message, sometimes, vary rarely, it will not produce the message.
>>
>> No relay set (used as window.postMessage targetOrigin), cannot send
>>cross-domain message
>>
>> Any help is appreciated, thanks
>> --
>> Wade Girard | Principal Software Engineer
>> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
>> Phone: 763.795.7798


Re: Noob Help

Posted by Ryan Baxter <rb...@apache.org>.
Hi Wade,

A couple of comments.

1.)  In your gadget you probably want to wrap gadgets.rpc.call in a
function passed to gadgets.util.registerOnLoadHandler to make sure the
gadget is completely initialized before making that rpc call.
2.)  In your container I would suggest you use the container feature.
It takes care of some of the nasty stuff with regards to registering
RPC callback functions.  All you then have to do is call
container.rpcRegister('initial_gadget_message', _messageHandler)

On Wed, Feb 12, 2014 at 2:16 PM, Wade Girard <Wa...@calabrio.com> wrote:
> I am trying to implement a container running under Shindig.
>
> I am having difficulty getting the rpc (Gadget->Contianer) communication working.
>
> Here is my simple gadget:
>
> <Module>
>
>   <ModulePrefs title="Hello World">
>
>     <Require feature="rpc" />
>
>   </ModulePrefs>
>
>   <UserPref name="myName" display_name="Name" default_value="Wade" />
>
>   <Content type="html">
>
> <![CDATA[
>
> <script type="text/javascript">
>
> gadgets.rpc.call(null, 'initial_gadget_message', null, 'Hello there! Pre-onload message sent successfully.');
>
> </script>
>
> <div id="widgetNode">Hello World</div>
>
> ]]>
>
>   </Content>
>
> </Module>
>
> Here is what I have done on the server (adapted)
>
> var id = "gadget_" + (this._static.id++);
>
> gadgets.rpc.register("initial_gadget_message", _messageHandler));
>
> var parent = window.location.origin; // also tried window.location.href
>
> iFrameNode.src = obj.iFrameUrls["default"] + "#parent=" parent + "&rpctoken=12345";
>
> iFrameNode.id = id;
>
> gadgets.rpc.setupReceiver(id);
>
> The container is at port 80, the gadget is at port 8080, on the same server (localhost)
> The gadget loads in the container, but most of the time produces this message, sometimes, vary rarely, it will not produce the message.
>
> No relay set (used as window.postMessage targetOrigin), cannot send cross-domain message
>
> Any help is appreciated, thanks
> --
> Wade Girard | Principal Software Engineer
> Calabrio, Inc. | 400 1st Avenue N, Ste 300 | Minneapolis, MN 55401
> Phone: 763.795.7798