Tuesday, April 6, 2010

Gotchas for Cross-domain Portlets via iFrames

We explored the available (Google-able) cross-domain iframe solutions a few months ago to see if using iFrames for cross-domain apps we would want to run as portlets would be a good idea. But the problem is that in most cross-domain hacks the iframed webapp must initiate the resizing of its parent container via changing its target link. You can imagine how that would cause some issues:
  1. The app you are trying to portlet-ize should not care whether it is in a portlet or not.
  2. The app you are trying to portlet-ize should not have to do the resizing, because that requires that all actions in the app that could affect its size need to call the refresh methods that set the URL target of themselves that the parent is watching in order to relay the new height and/or width.

This isn't to say that iFrames won't work in portals. For example, I know that John King of Geneseo U. uses iFrames in their portal but they own all of the portlet-ed apps and they are all on the same domain. However, for those exploring cross-domain iframed webapps in their portal, be aware of these gotchas.

If you want to develop apps that would be hosted in a different domain than the portal, you might look into Jasig's WebProxyPortlet (to proxy the external app), rails-portlet (if developing Rails apps), portletbridge, Grails Portlets Plugin (if developing Grails apps), etc. Also, we're working on an idea in-house at the moment that involves a completely client-side based javascript/jQuery solution using jsonp to communicate with cross-domain services. Jeremy B. is doing the heavy-lifting with the jQuery UI and JSON usage and following that, I'm hoping to make a gem to handle the creation of that javascript/HTML- that way it will serve up the client-side code after which jsonp is used solely for additional actions.

However, if you don't have control over the external app you want to show up in the portal, then Jasig's WebProxyPortlet or Mikael Lammentausa's html2jsr286 might be options.

Hope this helps someone else.

See also:

No comments: