You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Justin Wyllie <ju...@hotmail.co.uk> on 2010/05/19 16:49:01 UTC

adjustHeight in gadgets






Hi

I'm sorry. I think this question may be more suitable for the Shindig's User list. But I can't seem to subscribe to that list. (My subscribe emails to user-subscribe@shindig.apache.org  get bounced). I've mentioned this to the owner of this list.

We've just changed from using Google Friend Connect and the gmodules server to using Shindig.

My problem is this:

I'm rendering a gadget with a call like this:

<iframe id="gadget_2bc" src="http://localhost/gadgets/ifr?url=http://localhost/test1.xml&bpc=1" ></iframe>

The gadget tries to adjust its own height with this call:

gadgets.window.adjustHeight();

I have this in the ModulePrefs section:

<Require feature="dynamic-height"/>

When we render the gadget using the Google Friend Connect libary and call this method the iframe which contains the gadget gets a height set on it.

This does not happen now we're using Shindig. I have included what I think is the client-side Javascript with something that looks like this: mydomain/gadgets/js/shindig-container:rpc.js?c=1&debug=1&nocache=1

I wonder what I'm missing?

adjustHeight does seem to be defined as a method in open social

thanks

Justin Wyllie


 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
Do you have a story that started on Hotmail? Tell us now

RE: adjustHeight in gadgets

Posted by Justin Wyllie <ju...@hotmail.co.uk>.
Hi Tim

Thanks. This is re. the adjustHeight call from a gadget not working to resize the iframe in our Shindig container. 

I am using 1.1. You are right. Sorry.

I've now got this working. The results of my research are that in FF3.6 I did not need to add &parent=http://domain, where domain is the domain of my container, to the url which loads the gadget but I did in Chrome, Safari and IE7 and 8.

Additionally I tried calling a gadget rendering engine on the same domain as the container and on a remote domain.  The resize call from the gadget, adjustHeight(n) worked in all cases except IE7 using the remote domain.

So - my assumption is that all the browsers are using a samedomain method in the same domain case and trying to use the  postMessage method in the remote domain case. All support postMessage except IE7 which falls back to the inner iframe trick with rpc_relay.html in the remote domain case - and this is not working for some reason on my setup. (I'm working on it). In fact - I can't see a call looking for rpc_relay.html in the access logs.

I have not added any kind of token to the url for the iframe. I did add #rpctoken=123 at one point. I also had these lines of code in my container, after loading the main container javascript:

gadgets.rpc.setRelayUrl("widget_id1_gadget", "http://localhost/gadgets/ifr?url=http://localhost/test1.xml&bpc=1&view=default&parent=http://localhost#rpctoken=123");
gadgets.rpc.setAuthToken("widget_id1_gadget", "123");
gadgets.rpc.setupReceiver('widget_id1_gadget')    ; 

They certainly had an effect as if I mistmatched the tokens I got an error message from the container code but, as i say, they don't appear to be necessary.

Unfortunately I'm not sure why it now works. I've cleared cache and am always loading the gadgets with bpc=1 so i don't think it works because that code is still in the system.

So. All good except the pesky rpc_relay case.

Justin



 
>> I'm using the gadgets code in the gadget and I have included the client-side code to make my page a container.
> > 
> > I'm calling adjustHeight() in the gadget and I get this error message in the gadgets code:
> > 
> >      No relay set 
> > (used as window.postMessage targetOrigin), cannot send cross-domain 
> > message
> 
> <snip>
> 
> > I am using Shindig 1.0.
> 
> Are you sure? That error is only in the 1.1 javascript as far as I can
> tell.
> 
> >  My understanding is that rpc_relay.html is used by the gadgets code as the source of the iframe which it creates to pass a message to the container.
> 
> In 1.0 it's used as a fallback when there is no better channel
> available.
> 
> >From the error above it's using the window.postMessage channel (on your
> browser / domain setup) - which relies on knowing the url of the
> container to send messages to (what it's calling the relay in this
> situation).
> 
> In the iframe url, you can set the "parent" property to the full
> (urlencoded) domain of your container, which might solve your issue.
> 
> e.g. 
> 
> ifr?url=xxxxx&parent=http%3A%2F%2Fmycontainer.com
> 
> > You've mentioned keys and so on. But are these necessary? Is this something I have to do myself?
> 
> yup - they're important security considerations - as is not running
> shindig on the same domain as your container - otherwise you're allowing
> mallicious users to run any javascript they want on your domain.
> 
> 
> Tim
> 
 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

RE: adjustHeight in gadgets

Posted by Tim Wintle <ti...@teamrubber.com>.
On Thu, 2010-05-20 at 11:14 +0100, Justin Wyllie wrote:
> Thanks Tim
> 
> I'm using the gadgets code in the gadget and I have included the client-side code to make my page a container.
> 
> I'm calling adjustHeight() in the gadget and I get this error message in the gadgets code:
> 
>      No relay set 
> (used as window.postMessage targetOrigin), cannot send cross-domain 
> message

<snip>

> I am using Shindig 1.0.

Are you sure? That error is only in the 1.1 javascript as far as I can
tell.

>  My understanding is that rpc_relay.html is used by the gadgets code as the source of the iframe which it creates to pass a message to the container.

In 1.0 it's used as a fallback when there is no better channel
available.

>>From the error above it's using the window.postMessage channel (on your
browser / domain setup) - which relies on knowing the url of the
container to send messages to (what it's calling the relay in this
situation).

In the iframe url, you can set the "parent" property to the full
(urlencoded) domain of your container, which might solve your issue.

e.g. 

ifr?url=xxxxx&parent=http%3A%2F%2Fmycontainer.com

> You've mentioned keys and so on. But are these necessary? Is this something I have to do myself?

yup - they're important security considerations - as is not running
shindig on the same domain as your container - otherwise you're allowing
mallicious users to run any javascript they want on your domain.


Tim


RE: adjustHeight in gadgets

Posted by Justin Wyllie <ju...@hotmail.co.uk>.
Thanks Tim

I'm using the gadgets code in the gadget and I have included the client-side code to make my page a container.

I'm calling adjustHeight() in the gadget and I get this error message in the gadgets code:

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

This is the call trace: 

    logAtLevel()ifr?ur...l&bpc=1 (line 28)    log()ifr?ur...l&bpc=1 (line 27)    call()ifr?ur...l&bpc=1 (line 141)    registerDefault()ifr?ur...l&bpc=1 (line 284)    adjustHeight()ifr?ur...l&bpc=1 (line 297)    bigMeUp()
I am using Shindig 1.0. My understanding is that rpc_relay.html is used by the gadgets code as the source of the iframe which it creates to pass a message to the container. From the error message I haven't got as far as the container yet.

I have rpc_relay.html in my documentroot from the domain where I'm loading the gadget from (which happens to be the same domain the container is on). In container.js I've got 

     "parentRelayUrl" : "/rpc_relay.html", 

I'm guessing that this tells the gadgets javascript where to find rpc_relay.html but I'm not sure.

You've mentioned keys and so on. But are these necessary? Is this something I have to do myself?

Looking at the container code it looks to me like it is already set up to receive the call from the replay file. There is also a function to adjust the height of the gadget. (setHeight()). So my problem seems to be that the gadgets can't find the relay file or needs some other configuration to tell it to look for it.

I think this is my first problem and that the others e.g. keys may then become apparent.

Thanks for any steers






 
 adjustHeight needs to make a (client-side) cross-domain rpc call from
 your shindig domain to your container's domain - so you'll need a load
 of extra parameters on the iframe url to pass security tokens etc.
 
 Which version of shindig are you using? the RPC code has changed quite a
 bit between 1.0.x and 1.1.x.
 
 > I'm rendering a gadget with a call like this:
 > <iframe id="gadget_2bc" src="http://localhost/gadgets/ifr?url=http://localhost/test1.xml&bpc=1" > </iframe>
> 
 Have a look at the example container javascript that comes with shindig
 to see how it sets up the rpc on the outer page.
 
 If you want to generate your iframe code yourself then this page should
 be useful:
 https://cwiki.apache.org/confluence/display/SHINDIG/iframe+url+format
 
 Essentially (IIRC), you need to pass an rpctoken, and a module id to the
 iframe so that it can make the request back to the outer page.
 
 Then you'll need to set up listeners for these calls on the outer page -
 shindig wraps up all the cross-browser ways to do this into a fairly
 clean interface (see the example container.js file for how it does it)
 
 finally you'll probably want to write the code that actually adjusts the
 height (including a minimum/maximum height etc if you need it)
 
 In 1.0.X you also need to set up a relay page for some browsers - but
 I'm fairly certain that's gone in 1.1.x
 
 Tim Wintle
 
> 
 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

Re: adjustHeight in gadgets

Posted by Tim Wintle <ti...@teamrubber.com>.
adjustHeight needs to make a (client-side) cross-domain rpc call from
your shindig domain to your container's domain - so you'll need a load
of extra parameters on the iframe url to pass security tokens etc.

Which version of shindig are you using? the RPC code has changed quite a
bit between 1.0.x and 1.1.x.

> I'm rendering a gadget with a call like this:
> <iframe id="gadget_2bc" src="http://localhost/gadgets/ifr?url=http://localhost/test1.xml&bpc=1" ></iframe>

Have a look at the example container javascript that comes with shindig
to see how it sets up the rpc on the outer page.

If you want to generate your iframe code yourself then this page should
be useful:
https://cwiki.apache.org/confluence/display/SHINDIG/iframe+url+format

Essentially (IIRC), you need to pass an rpctoken, and a module id to the
iframe so that it can make the request back to the outer page.

Then you'll need to set up listeners for these calls on the outer page -
shindig wraps up all the cross-browser ways to do this into a fairly
clean interface (see the example container.js file for how it does it)

finally you'll probably want to write the code that actually adjusts the
height (including a minimum/maximum height etc if you need it)

In 1.0.X you also need to set up a relay page for some browsers - but
I'm fairly certain that's gone in 1.1.x

Tim Wintle