Armin, maybe you should put this on our wiki page. threads like this
tend to get lost easily in all the traffic.

-igor

On Wed, Mar 11, 2009 at 4:28 PM, Armin Bauer <armin.ba...@amiando.com> wrote:
> Hi everyone,
>
> we are currently working on an opensocial application based on wicket.
> Currently it is not possible to use the ajax functionality of wicket in an
> opensocial app.
>
> opensocial is based on iframes which run your html / js in a seperate
> domain. If you build a widget for myspace.com for example, your html will
> run in msappspace.com which will prevent ajax call due to cross domain
> browser security. Luckily there is a opensocial method
> "gadgets.io.makeRequest" to pull xml content from your backend which is
> proxied through the opensocial container and basically works like an ajax
> request.
>
> so i created a bridge which replaces the XHR of wicket-ajax.js with an
> implementation based on makeRequest. Without further ado:
>
> <script type="text/javascript">
>
> Wicket.Ajax.createTransport = function() {
>   return {
>
>       open: function(method, url, async) {
>           this.url = url;
>       },
>
>       setRequestHeader: function(key, value) {
>
>       },
>             send: function(body) {
>           var req_params = new Object();
>           req_params[gadgets.io.RequestParameters.CONTENT_TYPE] =
> gadgets.io.ContentType.TEXT;
>           var req = gadgets.io.makeRequest("http://your.server.com"; +
> this.url + "&" + body, this.callback.bind(this), req_params);
>       },
>             callback: function(data) {
>           this.responseText = data.text;
>           this.status = 200;
>           this.readyState = 4;
>           this.onreadystatechange();
>       },
>             getResponseHeader: function(key) {
>           return null;
>       },
>             abort: function() {
>             }
>     };
> }
>
> </script>
>
> By including this script below your wicket-ajax script in the opensocial app
> you can use finally use ajax functionality directly on the canvas. It should
> work completely transparent so no changes in your wicket code should be
> required. Developing / porting wicket code to opensocial apps should be a
> lot easier now :)
>
> Note that this example does not support error handling, headers, aborting
> and GET request also do not work completely. Adding this functionality
> should be easy however. Feel free to use / modify / publish the code as you
> like.
>
> Best Regards,
> Armin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to