com.ibm.mashups.iwidget
Interface io


public io

This interface defines support the iContext is supplying regarding IO operations.

    this.iContext.io.rewriteURI(aUri);


Method Summary
 XMLHttpRequest XMLHttpRequest()
           This object wraps the native XMLHttpRequest support to provide a consistent page in the face of asynchronous updates, especially those which may cause server-side coordination between the server-side components related to multiple iWidgets on the page.
 String rewriteURI(String uri, Boolean isXhr)
           This method takes a URI as a parameter and returns a URI which the browser can resolve for accessing the supplied URI.
 void xhrReq(Object args)
           This convenience method creates a new XMLHttpRequest and send the request with all supplied arguments on the XMLHttpRequest.
 

Method Detail

XMLHttpRequest

XMLHttpRequest XMLHttpRequest()
This object wraps the native XMLHttpRequest support to provide a consistent page in the face of asynchronous updates, especially those which may cause server-side coordination between the server-side components related to multiple iWidgets on the page.

Returns:
returns native XMLHttpRequest object.

rewriteURI

String rewriteURI(String uri,
                  Boolean isXhr)
This method takes a URI as a parameter and returns a URI which the browser can resolve for accessing the supplied URI. Examples of usage include resolving a relative URI against the source of the iWidget's definition and resolving other URIs to address any intermediate gateways, such as a proxy server.

   Sample usage that resolves URI to address a proxy server ,assume url to proxy server is "/mum/proxy".
    var aUri = "http://yourco.com/mytest.js";
    var rc = this.iContext.io.rewriteURI(aUri);
     the result will be "/mum/proxy/http/yourco.com/mytest.js"

   Sample usage that resolves a relative URI against the source of the iWidget's deinfition
    Assume iwidget is included on a page as follows:
    <span id="yourcoWidget" class="iw-iWidget"><a class="iw-Definition" href="/mm/widget-catalog/yourcoWidget.xml"></a></span>

    var aUri = "mytest.js";
    var rc = this.iContext.io.rewriteURI(aUri);
     the result will be "/mm/widget-catalog/mytest.js"

   Sample usage that resolves a relative URI against the source of the iWidget's deinfition for an image resource.
    Assume iwidget is included on a page as follows:
    <span id="yourcoWidget" class="iw-iWidget"><a class="iw-Definition" href="http://yourco.com/mm/widget-catalog/yourcoWidget.xml"></a></span>

   the url for the img resource of following code will be "http://yourco.com/mm/widget-catalog/mytest.gif"
    var aUri = "mytest.gif";
    var returnUri = this.iContext.io.rewriteURI(aUri,false);
    var img = dojo.byId(id);
    img.src = returnUri;

Parameters:
uri - URI that needs to be resolved. Must not be null.
isXhr - optional,boolean indicating the url is used as xhr. If no value is provided, the default is true.
Returns:
return a URI which the browser can resolve for accessing the supplied URI. Must not be null.

xhrReq

void xhrReq(Object args)
This convenience method creates a new XMLHttpRequest and send the request with all supplied arguments on the XMLHttpRequest.
The supported fields within the arguments object include:

{
    "requestVerb": { "get" | "post" | "put" | "delete"},
   "url": { url},
   "handleAs": { handleAs},
   "sync": { boolean},
   "preventCache": { boolean},
   "content": { content},
   "headers": { headers},
   "timeout": { int},
   "user": { user},
   "password": { password},
   "form": { form},
   "msgData": { msgData},
   "load": { load},
   "error": { error},
   "handle": { handle}
}

Parameters:
args - supported properties as listed above.


Copyright IBM Corp. 2010 All Rights Reserved.