PDA

View Full Version : An idea to abort fileupload?



EagleEye666666
23 Jan 2009, 11:21 AM
I want to give the user the ability to abort the fileupload, cuz my fileupload can consists a max Size up to 52 MB. And maybe the user forget some file and while uploading he is recognizing his mistake.

Some ideas? I mean the messagebox has already a abort button which closes the box :D but how to kill the request(the formsubmit)?

some code of the box:

final MessageBox box = new MessageBox();
box.setTitle("Please wait");
box.setMessage("Uploading files...");
box.setType(MessageBoxType.WAIT);
box.setProgressText("Uploading...");
box.setButtons(Dialog.CANCEL);
box.setClosable(false);
// box.addCallback( // TODO listener to kill the form submit);

regards.

EagleEye666666
28 Jan 2009, 11:55 AM
I was more thinking and searching ways... one way could be to remove/kill the iFrame which is used for the general submit of an FromPanel..

Somebody has an idea how to get this iframe and remove it? It might be some good idea to directly support cancel of submiting a form..., because the beforesubmit just can check a few things and you are limited..

There is actually no way to stop a started upload request... and you cant even check the size before and use the BeforeSubmit event ...

I need to accieve this.. my server sends response that the request is rejected but the form still sends the data to the iframe... it is annoying.

regards

gslender
30 Jan 2009, 2:19 AM
the solution is that the server, upon receiving any data, can notify the client of the outcome (both total size and progress so far) so you can do it, you just need to enable the server to be apart of the solution

EagleEye666666
30 Jan 2009, 3:38 AM
the solution is that the server, upon receiving any data, can notify the client of the outcome (both total size and progress so far) so you can do it, you just need to enable the server to be apart of the solution

serverside is done... Commons FileUpload... rejects the request also writes response that fileupload has been canceled. I just have lag of knowledge to remove/kill the iframe on clientside. Can you give me some hint? How it could be done? somehow i have to get it from the DOM and remove it. (byID? I checked there some stuff, but i did not succeed)

thanks for responding again.regards

gslender
30 Jan 2009, 3:52 AM
Mmm, not going to be easy - look for iframe in the dom with a attribute name that starts with "gxt.formpanel-"

Search the dom like this...


Element[] iframes = XDOM.getBodyEl().select("iframe");
for(Element e : iframes) {
El f = El.fly(e);
if (f.dom.getAttribute("name").startsWith("gxt.formpanel-")) {
// f is my frame then
}

EagleEye666666
30 Jan 2009, 5:56 AM
Mmm, not going to be easy - look for iframe in the dom with a attribute name that starts with "gxt.formpanel-"

Search the dom like this...


Element[] iframes = XDOM.getBodyEl().select("iframe");
for(Element e : iframes) {
El f = El.fly(e);
if (f.dom.getAttribute("name").startsWith("gxt.formpanel-")) {
// f is my frame then
}

Ok now i have the iframe (thanks by the way :D) and recreating it would be the best way i guess cuz removing crashed the nodeList DOM somehow....

like this:

private void createFrame() {
Element dummy = DOM.createDiv();
DOM.setInnerHTML(dummy, "<iframe src=\"javascript:''\" name='" + frameName
+ "' style='position:absolute;width:0;height:0;border:0'>");

iframe = DOM.getFirstChild(dummy);
}


and this new created setting as new iframe (I have doubts it will not work right?)

problem is that DOM.setInnerHTML i cant use like this i do not really get why... it is just copied...

hmm... it's killing me a bit ... that iam not able to.

some thought: maybe it would be nice to think over and find a way to let the user get/set it from the FormPanel?? some kind of build in cancel (of course if this will work ever) ??