<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flex2 &amp; DWR</title>
	<atom:link href="http://blog.gtuhl.com/2007/04/04/flex2-dwr/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/</link>
	<description>Development, IT, Gadgets, and Startups</description>
	<lastBuildDate>Mon, 15 Aug 2011 08:57:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: gtuhl</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-174</link>
		<dc:creator>gtuhl</dc:creator>
		<pubDate>Tue, 25 Mar 2008 15:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-174</guid>
		<description>Awesome, glad it is useful.  Let me know how it turns out, it has been about a year since I last worked heavily with Flex so it is quite possible that some of the rough edges are smoothed over.  The platform has loads of great ideas that if fully implemented would be pretty nice.  We are actually about to start pulling Flex back into the code for certain tasks (like charting and visualization) so i&#039;ll get to see what has changed then.</description>
		<content:encoded><![CDATA[<p>Awesome, glad it is useful.  Let me know how it turns out, it has been about a year since I last worked heavily with Flex so it is quite possible that some of the rough edges are smoothed over.  The platform has loads of great ideas that if fully implemented would be pretty nice.  We are actually about to start pulling Flex back into the code for certain tasks (like charting and visualization) so i&#8217;ll get to see what has changed then.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kenton</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-173</link>
		<dc:creator>kenton</dc:creator>
		<pubDate>Tue, 25 Mar 2008 15:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-173</guid>
		<description>I know you have moved on, but I am considering going down a similar path (we built a DWR/Hibernate/JS/HTML application). I am very glad I have found your blog detailing the ExternalInterface bug which would have been a definite deal breaker, and since from what I see Flash Player 9 update 3 has a penetration slightly higher than 2%, that looked like a deal breaker for me... However with DWR 3.0 allowing JSON requests I think we could actually bypass this issue all together.

I&#039;ll keep you posted on my progress, thanks for the fantastic information</description>
		<content:encoded><![CDATA[<p>I know you have moved on, but I am considering going down a similar path (we built a DWR/Hibernate/JS/HTML application). I am very glad I have found your blog detailing the ExternalInterface bug which would have been a definite deal breaker, and since from what I see Flash Player 9 update 3 has a penetration slightly higher than 2%, that looked like a deal breaker for me&#8230; However with DWR 3.0 allowing JSON requests I think we could actually bypass this issue all together.</p>
<p>I&#8217;ll keep you posted on my progress, thanks for the fantastic information</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stranger</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-136</link>
		<dc:creator>stranger</dc:creator>
		<pubDate>Thu, 17 Jan 2008 11:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-136</guid>
		<description>Hi,

I am trying to get data from a oracle database which can be done by executing a dwr.execute method from flex. for doing that, I am using External Interface API to call a javascript function and does this dwr.execute method. But , it doesn;t work.
can you help me in this. 

Thanks for the help in advance,
stranger.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am trying to get data from a oracle database which can be done by executing a dwr.execute method from flex. for doing that, I am using External Interface API to call a javascript function and does this dwr.execute method. But , it doesn;t work.<br />
can you help me in this. </p>
<p>Thanks for the help in advance,<br />
stranger.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keshav Prasad</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-135</link>
		<dc:creator>Keshav Prasad</dc:creator>
		<pubDate>Thu, 17 Jan 2008 10:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-135</guid>
		<description>// ActionScript file
package someLib
{
  import flash.external.ExternalInterface;
  import mx.collections.ArrayCollection;
  import mx.utils.UIDUtil;

  /**
   * This class provides access to Dwr.  It assumes
   * that flex is being used in an Html container that
   * has access to dwrWrapper.js.
   * Each instance wraps a single Dwr controller.
   */
  public class DwrWrap
    private var functionMap:Array;
    private var wrapUID:String;

    public var controllerName:String;

    /**
     * Constructor for DwrWrap.  Initializes function
     * map and registers ExternalInterface callbacks
     * @param controllerName The name of the
     *   JS/Dwr controller to use
     */
    public function DwrWrap(controllerName:String){
      this.controllerName = controllerName;
      this.functionMap = new Array();
      this.wrapUID = UIDUtil.getUID(this);

      // register AS3 callbacks as name + UUID
      ExternalInterface.addCallback(&quot;handleJsCallback&quot; +
        this.wrapUID.replace(/-/gi, &quot;&quot;),
        handleJsCallback);
      ExternalInterface.addCallback(&quot;handleJsError&quot; +
        this.wrapUID.replace(/-/gi, &quot;&quot;),
        handleJsError);
    }

    /**
     * Method that calls JS using ExternalInterface.
     * @param jsMethodName JS/Dwr function to call
     * @param jsArgs A single argument or an
     *   ArrayCollection of arguments to use in JS call
     * @param callback An untyped object with callback
     *   and errorHandler properties
     */
    public function serverCall(jsMethodName:String,
        jsArgs:*, callback:Object = null):void{

      var jsCallback:Object = new Object();

      // map UUIDs to AS3 callback function references
      var callbackUID:String =
        UIDUtil.getUID(callback.callback);
      jsCallback.callback = callbackUID;
      functionMap[callbackUID] = callback.callback;

      var errorUID:String =
        UIDUtil.getUID(callback.errorHandler);
      jsCallback.errorHandler = errorUID;
      functionMap[errorUID] = callback.errorHandler;

      // make sure jsArgs is an array - assumption in JS
      if (jsArgs is ArrayCollection){
        jsArgs = jsArgs.toArray();
      }
      else if (!(jsArgs is Array)){
        var argArray:Array = new Array();
        argArray.push(jsArgs);
        jsArgs = argArray;
      }
      else if (jsArgs == null){
        jsArgs = new Array();
      }

      ExternalInterface.call(&quot;dwrCall&quot;, this.wrapUID,
        (controllerName + &quot;.&quot; + jsMethodName), jsArgs,
        jsCallback);
    }  

    /**
     * This method receives the callback from JS and
     * then calls the appropriate AS3 callback
     * @param dwrResponse The response from Dwr
     * @param asCallback UUID of AS3 function to call
     */
    public function handleJsCallback(dwrResponse:*,
        asCallback:String):void{

      // use the UUID to look up the function reference
      var callbackFunction:Function =
        functionMap[asCallback];

      if (callbackFunction != null){
        delete functionMap[asCallback];
        callbackFunction(dwrResponse);
      }
    }

    /**
     * This method receives errors from JS and
     * then calls the appropriate AS3 errorHandler
     * @param dwrResponse The error response from Dwr
     * @param asErrorHandler UUID of the AS3 function
     */		
    public function handleJsError(dwrResponse:*,
        asErrorHandler:String):void{

      // use the UUID to look up the function reference
      var errorFunction:Function =
        functionMap[asErrorHandler];

      if (errorFunction != null){
        delete functionMap[asErrorHandler];
        errorFunction(dwrResponse);
      }
    }
  }
}</description>
		<content:encoded><![CDATA[<p>// ActionScript file<br />
package someLib<br />
{<br />
  import flash.external.ExternalInterface;<br />
  import mx.collections.ArrayCollection;<br />
  import mx.utils.UIDUtil;</p>
<p>  /**<br />
   * This class provides access to Dwr.  It assumes<br />
   * that flex is being used in an Html container that<br />
   * has access to dwrWrapper.js.<br />
   * Each instance wraps a single Dwr controller.<br />
   */<br />
  public class DwrWrap<br />
    private var functionMap:Array;<br />
    private var wrapUID:String;</p>
<p>    public var controllerName:String;</p>
<p>    /**<br />
     * Constructor for DwrWrap.  Initializes function<br />
     * map and registers ExternalInterface callbacks<br />
     * @param controllerName The name of the<br />
     *   JS/Dwr controller to use<br />
     */<br />
    public function DwrWrap(controllerName:String){<br />
      this.controllerName = controllerName;<br />
      this.functionMap = new Array();<br />
      this.wrapUID = UIDUtil.getUID(this);</p>
<p>      // register AS3 callbacks as name + UUID<br />
      ExternalInterface.addCallback(&#8220;handleJsCallback&#8221; +<br />
        this.wrapUID.replace(/-/gi, &#8220;&#8221;),<br />
        handleJsCallback);<br />
      ExternalInterface.addCallback(&#8220;handleJsError&#8221; +<br />
        this.wrapUID.replace(/-/gi, &#8220;&#8221;),<br />
        handleJsError);<br />
    }</p>
<p>    /**<br />
     * Method that calls JS using ExternalInterface.<br />
     * @param jsMethodName JS/Dwr function to call<br />
     * @param jsArgs A single argument or an<br />
     *   ArrayCollection of arguments to use in JS call<br />
     * @param callback An untyped object with callback<br />
     *   and errorHandler properties<br />
     */<br />
    public function serverCall(jsMethodName:String,<br />
        jsArgs:*, callback:Object = null):void{</p>
<p>      var jsCallback:Object = new Object();</p>
<p>      // map UUIDs to AS3 callback function references<br />
      var callbackUID:String =<br />
        UIDUtil.getUID(callback.callback);<br />
      jsCallback.callback = callbackUID;<br />
      functionMap[callbackUID] = callback.callback;</p>
<p>      var errorUID:String =<br />
        UIDUtil.getUID(callback.errorHandler);<br />
      jsCallback.errorHandler = errorUID;<br />
      functionMap[errorUID] = callback.errorHandler;</p>
<p>      // make sure jsArgs is an array &#8211; assumption in JS<br />
      if (jsArgs is ArrayCollection){<br />
        jsArgs = jsArgs.toArray();<br />
      }<br />
      else if (!(jsArgs is Array)){<br />
        var argArray:Array = new Array();<br />
        argArray.push(jsArgs);<br />
        jsArgs = argArray;<br />
      }<br />
      else if (jsArgs == null){<br />
        jsArgs = new Array();<br />
      }</p>
<p>      ExternalInterface.call(&#8220;dwrCall&#8221;, this.wrapUID,<br />
        (controllerName + &#8220;.&#8221; + jsMethodName), jsArgs,<br />
        jsCallback);<br />
    }  </p>
<p>    /**<br />
     * This method receives the callback from JS and<br />
     * then calls the appropriate AS3 callback<br />
     * @param dwrResponse The response from Dwr<br />
     * @param asCallback UUID of AS3 function to call<br />
     */<br />
    public function handleJsCallback(dwrResponse:*,<br />
        asCallback:String):void{</p>
<p>      // use the UUID to look up the function reference<br />
      var callbackFunction:Function =<br />
        functionMap[asCallback];</p>
<p>      if (callbackFunction != null){<br />
        delete functionMap[asCallback];<br />
        callbackFunction(dwrResponse);<br />
      }<br />
    }</p>
<p>    /**<br />
     * This method receives errors from JS and<br />
     * then calls the appropriate AS3 errorHandler<br />
     * @param dwrResponse The error response from Dwr<br />
     * @param asErrorHandler UUID of the AS3 function<br />
     */<br />
    public function handleJsError(dwrResponse:*,<br />
        asErrorHandler:String):void{</p>
<p>      // use the UUID to look up the function reference<br />
      var errorFunction:Function =<br />
        functionMap[asErrorHandler];</p>
<p>      if (errorFunction != null){<br />
        delete functionMap[asErrorHandler];<br />
        errorFunction(dwrResponse);<br />
      }<br />
    }<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gtuhl</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-132</link>
		<dc:creator>gtuhl</dc:creator>
		<pubDate>Mon, 14 Jan 2008 19:32:01 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-132</guid>
		<description>That&#039;s a different way to approach it and seems like it might be possible.  I suspect you could look at the generated JS stub files from DWR to see what URLs it is using internally and call out to those from Actionscript.

There would probably be some serialization/de-serialization effort for parameters and such, before doing this hacked-bridge approach I started writing basically a DWREngine.as to serve as a more complete Actionscript alternative but ran into enough issues that I didn&#039;t feel up to the effort.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a different way to approach it and seems like it might be possible.  I suspect you could look at the generated JS stub files from DWR to see what URLs it is using internally and call out to those from Actionscript.</p>
<p>There would probably be some serialization/de-serialization effort for parameters and such, before doing this hacked-bridge approach I started writing basically a DWREngine.as to serve as a more complete Actionscript alternative but ran into enough issues that I didn&#8217;t feel up to the effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Haliday</title>
		<link>http://blog.gtuhl.com/2007/04/04/flex2-dwr/comment-page-1/#comment-131</link>
		<dc:creator>Mark Haliday</dc:creator>
		<pubDate>Mon, 14 Jan 2008 19:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://gtuhl.nfshost.com/blog/?p=13#comment-131</guid>
		<description>This is interesting, but isn&#039;t there a way to have ActionScript call DWR directly without going through the JavaScript?  Something like the URLLoader, URLRequest, etc.?</description>
		<content:encoded><![CDATA[<p>This is interesting, but isn&#8217;t there a way to have ActionScript call DWR directly without going through the JavaScript?  Something like the URLLoader, URLRequest, etc.?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

