Opened 13 years ago

Closed 13 years ago

Last modified 10 years ago

#1170 closed defect (fixed)

[patch][cla] dojo.io.bind IframeTransport "url:" does not work

Reported by: guest Owned by: James Burke
Priority: high Milestone:
Component: IO Version: 0.3
Keywords: Cc:
Blocked By: Blocking:

Description

The "url:" parameter for dojo.io.bind is ignored when using IframeTransport?.

The following code snippet demonstrates the problem. With 'transport: "XMLHTTPTransport"', it works as expected, but 'transport: "IframeTransport?"', causes the browser to make many requests for "dojo/iframe_history.html" and [filename.html]

<script type="text/javascript">
  dojo.require("dojo.event.*");
  dojo.require("dojo.io.*");
  dojo.require("dojo.io.IframeIO");
</script>
<script type="text/javascript">
  var requestObj = dojo.io.bind({
    url: "dummyfile",
    mimetype: "text/html",
    transport: "IframeTransport",
    load: function(type, data, evt){
      alert("Success!: " + data);
    },
    error: function(type, error) {
      alert("Error: " + error.message);
    }
});
</script>

Change History (11)

comment:1 Changed 13 years ago by dylan

Milestone: 0.4
Owner: changed from alex to dylan

What would you expect dummyfile to do? The iframe_history file is used when initially creating the iframe. Are you saying that it isn't successfully posting to that url?

comment:2 Changed 13 years ago by James Burke

I looked at this briefly when it was first reported on dojo-interest: the problem is that IframeIO assumes there is always a form node involved in the process. However, the use case above was that there was no form node, and they just wanted to load the url file directly as the response document. You can take tests/io/test_IframeIO.html.html, remove the form and add url: "IframeIOResponse.html" to the bindArgs to reproduce the problem.

comment:3 Changed 13 years ago by guest

I ran into this problem too. The following patch seems like it's fixing the problem:

Index: IframeIO.js
===================================================================
--- IframeIO.js (revision 5026)
+++ IframeIO.js (working copy)
@@ -101,7 +101,7 @@
                        // otherwise we post a GET string by changing URL location for the
                        // iframe
                        var query = dojo.io.argsFromMap(this.currentRequest.content);
-                       var tmpUrl = (cr.url.indexOf("?") > -1 ? "&" : "?") + query;
+                       var tmpUrl = cr.url + (cr.url.indexOf("?") > -1 ? "&" : "?") + query;
                        dojo.io.setIFrameSrc(this.iframe, tmpUrl, true);
                }
        }
@@ -173,8 +173,10 @@
                if(req["_originalAction"]){
                        req.formNode.setAttribute("action", req._originalAction);
                }
-               req.formNode.setAttribute("target", req._originalTarget);
-               req.formNode.target = req._originalTarget;
+               if(req["_originalTarget"]){
+                       req.formNode.setAttribute("target", req._originalTarget);
+                       req.formNode.target = req._originalTarget;
+               }

                var contentDoc = function(iframe_el){
                        var doc = iframe_el.contentDocument || // W3

comment:4 Changed 13 years ago by dylan

Summary: dojo.io.bind IframeTransport "url:" does not work[patch][need cla] dojo.io.bind IframeTransport "url:" does not work

do we have a CLA on file for "guest"?

comment:5 Changed 13 years ago by dylan

This looks like a useful patch, but we can't accept it without knowing who submitted it, and if they have a CLA on file...

comment:6 Changed 13 years ago by James Burke

Owner: changed from dylan to James Burke

I'll see what I can do without looking at the patch. I should be able to use BrowserIO as a guide.

comment:7 Changed 13 years ago by gregory.murray@…

The user that submitted this is now under CLA.

comment:8 Changed 13 years ago by dylan

Summary: [patch][need cla] dojo.io.bind IframeTransport "url:" does not work[patch][cla] dojo.io.bind IframeTransport "url:" does not work

Greg, for the record, who is guest?

comment:9 Changed 13 years ago by James Burke

(In [6181]) Fixes #1011, support application/json. Also fixed IframeIO.js canHandle: the stricter checking I did in dojo.io.bind() caused IframeTransport? binds to fail unless they had a file upload field. Since we are going to allow using url: with IframeTransport? (references #1170) I removed the file input requirement for IframeTransport?.

comment:10 Changed 13 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [6182]) Fixes #1170. Confirmed with Dylan that person who submitted the patch is from Sun and is covered by their CLA. In addition to the patch, I added a little extra protection around formNode accesses.

comment:11 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.