PDA

View Full Version : How prevent 2 GET requests when downloading file?



simonr25
29 Jul 2013, 8:04 PM
Hello,

The below code (which is invoked following selecting an icon in an action column) sometimes (not always)
leads to 2 GET requests being sent to the server, observed in the NET browser window - (this occassionally
leads to unwanted side effects, e.g. extra window containing the pdf contents covering the viewport - possible slowing down of download).

The code is downloading a pdf to be viewed in an iframe.


Ext.getDom('iframe-win').src = "viewpdf.action?id=11"


[13:16:38.274] GET http://localhost:8080/viewer/viewpdf.action?id=11 [HTTP/1.1 200 OK 27ms]
[13:16:38.693] GET http://localhost:8080/viewer/viewpdf.action?id=11 [HTTP/1.1 200 OK 25ms]

Would you know why this is happening?
Is it possible to ensure just 1 request is sent?

Thank you,
S

slemmon
2 Aug 2013, 12:55 PM
Hard to say without seeing your code. Can you share the code for your grid with the actioncolumn's handler that requests the PDF from the server?

simonr25
4 Aug 2013, 10:42 AM
Hello,
please find below the app.js which sometimes gives rise to the 2
Ajax requests.

Following further investigation, it is not due to selecting an icon
in the action column.

It seems to be due to the expand command. When the east region is
expanded or collapsed, 2 AJAX requests often get sent.

One problem I occassionally get, when using firefox, is that on
expanding or collapsing the region, a new browser window (tab) is
displayed covering the original window, showing the pdf contents.

Am using firefox 22.0, applications->PDF>Preview in Firefox

I do not understand why this is happening - how to avoid it.
I have tried making the region non-collapsible, which hitherto
has worked.

<CODE>
Ext.define('My.view.PdfView', {
extend:'Ext.panel.Panel',
alias:'widget.PdfView',
layout: 'fit',
collapsible:true,
collapsed:true,
resizable:true,
width: 320,
id: 'pdf-cmp',
items: {
xtype: 'component',
id: 'iframe-win',
autoEl: {
tag: 'iframe',
src: ''
}
}

});

Ext.define('My.view.Viewport', {
extend:'Ext.container.Viewport',

layout: 'border',
items:[
{
xtype:'button',
region: 'center',
handler: function() {
var p = Ext.getCmp('pdf-cmp');
p.expand();
Ext.getDom('iframe-win').src = "viewpdf.action";
}
},
{
xtype:'PdfView',
region: 'east',
width: 320,
height: 550
}
]

});

Ext.application({
name: 'My',
launch: function () {
vp = Ext.create('My.view.Viewport', {});
}
});
</CODE>