Transfering a file using DWR 3.0 disables the "input" events

View: New views
3 Messages — Rating Filter:   Alert me  

Transfering a file using DWR 3.0 disables the "input" events

by Antonio Cabrera :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I'm  using dojo (not really the problem) and the last DWR CVS version (compiled on jun-18-2009)

Basically, I connect the "onchange" events of an "<input type="file" >" and when the event is fired, I call a function that transfer the file to the server.

All works fine, (the callback function is executed)... but the input doesn't fire the 'onchange' event anymore.

The problem is common to Firefox, Chrome and IE.

I'm not really sure if this is an Issue or is the correct behaviour.

here you are an example of code:

HTML:
<input type="file" id="theFileInputId" />

JAVASCRIPT:

       constructor:function() {
          var fileInput = dojo.byId("theFileInputId");
          dojo.connect(fileInput, "onchange",this, "_onUploadFileChange");
       },
_onUploadFileChange: function(evt){
var input = evt.target;
console.debug("file for upload changed:" + input.value);
if(input.value) {
JVirtualDocumentSrv.addDocument(dwr.util.getValue(input),  {
callback: function(data){console.debug("file uploaded:" + data.name);},
errorHandler: function(message) {console.debug("file upload failed:" + message);}
})
}
}

JAVA

  public class JVirtualDocumentSrv {
     public void addDocument( FileTransfer file ) throws Exception {
        InputStream in = file.getInputStream();
        try {
          createFile(file.getName(), in);
        } finally {
          in.close();
        }
     }
...



Charlas más divertidas con el nuevo Windows Live Messenger

Re: Transfering a file using DWR 3.0 disables the "input" events

by XMaNIaC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, it's replaced by another input file

On Thu, Jun 18, 2009 at 12:08 PM, Antonio Cabrera <antoniocabreraperez@...> wrote:
I'm  using dojo (not really the problem) and the last DWR CVS version (compiled on jun-18-2009)

Basically, I connect the "onchange" events of an "<input type="file" >" and when the event is fired, I call a function that transfer the file to the server.

All works fine, (the callback function is executed)... but the input doesn't fire the 'onchange' event anymore.

The problem is common to Firefox, Chrome and IE.

I'm not really sure if this is an Issue or is the correct behaviour.

here you are an example of code:

HTML:
<input type="file" id="theFileInputId" />

JAVASCRIPT:

       constructor:function() {
          var fileInput = dojo.byId("theFileInputId");
          dojo.connect(fileInput, "onchange",this, "_onUploadFileChange");
       },
_onUploadFileChange: function(evt){
var input = evt.target;
console.debug("file for upload changed:" + input.value);
if(input.value) {
JVirtualDocumentSrv.addDocument(dwr.util.getValue(input),  {
callback: function(data){console.debug("file uploaded:" + data.name);},
errorHandler: function(message) {console.debug("file upload failed:" + message);}
})
}
}

JAVA

  public class JVirtualDocumentSrv {
     public void addDocument( FileTransfer file ) throws Exception {
        InputStream in = file.getInputStream();
        try {
          createFile(file.getName(), in);
        } finally {
          in.close();
        }
     }
...



Charlas más divertidas con el nuevo Windows Live Messenger


Re: Transfering a file using DWR 3.0 disables the "input" events

by Lance Java :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

DWR pollutes the file object attributes and changes it's name prior to posting it so it clones it and swaps prior to doing a post. I guess we could be smarter here and revert the original back to it's original state instead.

Hopefully there's a simple workaraound for your problem.

2009/6/18 Jose Noheda <jose.noheda@...>
Yes, it's replaced by another input file


On Thu, Jun 18, 2009 at 12:08 PM, Antonio Cabrera <antoniocabreraperez@...> wrote:
I'm  using dojo (not really the problem) and the last DWR CVS version (compiled on jun-18-2009)

Basically, I connect the "onchange" events of an "<input type="file" >" and when the event is fired, I call a function that transfer the file to the server.

All works fine, (the callback function is executed)... but the input doesn't fire the 'onchange' event anymore.

The problem is common to Firefox, Chrome and IE.

I'm not really sure if this is an Issue or is the correct behaviour.

here you are an example of code:

HTML:
<input type="file" id="theFileInputId" />

JAVASCRIPT:

       constructor:function() {
          var fileInput = dojo.byId("theFileInputId");
          dojo.connect(fileInput, "onchange",this, "_onUploadFileChange");
       },
_onUploadFileChange: function(evt){
var input = evt.target;
console.debug("file for upload changed:" + input.value);
if(input.value) {
JVirtualDocumentSrv.addDocument(dwr.util.getValue(input),  {
callback: function(data){console.debug("file uploaded:" + data.name);},
errorHandler: function(message) {console.debug("file upload failed:" + message);}
})
}
}

JAVA

  public class JVirtualDocumentSrv {
     public void addDocument( FileTransfer file ) throws Exception {
        InputStream in = file.getInputStream();
        try {
          createFile(file.getName(), in);
        } finally {
          in.close();
        }
     }
...



Charlas más divertidas con el nuevo Windows Live Messenger