Hi.. sencha forum member i am little bit confuse in my report export process. I am able to generate the report in pdf form using jasper report and java.
The report generated not available to be get download to the client side.
I am generating pdf file using below code
Code:
public void getTaskreportPDF(Session openSession,HttpServletRequest request,
HttpServletResponse response) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/contact","root","root");
Map params = getParameters(openSession);
Date date = new Date();
String reportfileName = "report"+date.getDate()+"-"+date.getMonth()+"-"+date.getYear()+"-"+date.getTime()+".pdf";
JasperDesign jasperDesign = JRXmlLoader.load(this.getClass().getResourceAsStream("/com/gantt/report/ganttreport.jrxml"));
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperprint = JasperFillManager.fillReport(jasperReport, params,con);
JRAbstractExporter exporterPDF = new JRPdfExporter();
exporterPDF.setParameter(JRExporterParameter.JASPER_PRINT, jasperprint);
exporterPDF.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
response.setHeader("Content-Disposition", "inline;filename="+ reportfileName);
response.setContentType("application/pdf");
exporterPDF.exportReport();
} catch(Exception exception) {
System.out.println("Error occured " +exception.getMessage());
}
}
when i view my firebug net tab i am getting response as
Code:
Response Headersview source| Content-Disposition |
inline;filename=report21-0-112-1327133892240.pdf |
| Content-Type |
application/pdf |
| Date |
Sat, 21 Jan 2012 08:18:18 GMT |
| Server |
Apache-Coyote/1.1 |
| Transfer-Encoding |
chunked |
Request Headersview source
| Accept |
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
| Accept-Charset |
ISO-8859-1,utf-8;q=0.7,*;q=0.7 |
| Accept-Encoding |
gzip, deflate |
| Accept-Language |
en-us,en;q=0.5 |
| Connection |
keep-alive |
| Cookie |
JSESSIONID=61B442502AEF0B8F445E4FC048FE9478; bmeval=1327129699647 |
| Host |
localhost:8085 |
| Referer |
http://localhost:8085/Gantt/ |
| User-Agent |
Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 |
Request Headers From Upload Stream
| Content-Length |
45 |
| Content-Type |
multipart/form-data; boundary=---------------------------181274673728 |
my response is correct and i am getting the pdf file having size of 4 kb. but the problem is that the download dialog window is not available. so help me to find my problem so I can solve it.
my app.js is
Code:
Ext.onReady(function() {
Ext.QuickTips.init();
App.init();
});
TaskPriority = {
Low : 0,
Normal : 1,
High : 2
};
App = {
// Initialize application
init: function () {
//create the downloadframe at the init of your app
this.downloadFrame = Ext.getBody().createChild({
tag: 'iframe'
, cls: 'x-hidden'
, id: 'iframe'
, name: 'iframe'
});
//create the downloadform at the init of your app
this.downloadForm = Ext.getBody().createChild({
tag: 'form'
, cls: 'x-hidden'
, id: 'form'
, target: 'iframe'
});
var params = new Object();
var g = Ext.create("Gnt.panel.Gantt", {
height: '100%',
width: '99%',
renderTo: Ext.getBody(),
leftLabelField: 'Name',
loadMask: true,
startDate: start,
endDate: end,
multiSelect : true,
cascadeChanges : true,
viewPreset: 'weekAndDayLetter',
recalculateParents: false,
tbar: [{
iconCls : 'icon-pdf',
scale : 'large',
text : 'Export to PDF',
handler : function(button, event){
//code goes here
Ext.Ajax.request({
url: 'task/GetTaskReportPDF.action',
params: params,
form: App.downloadForm,
isUpload: true,
// method: 'POST',
success : function(response, option){
//this.gestioneRisposta(response);
console.log("success");
}
,failure :function(response, option){
console.log("failure");
}
,scope : this
});
}
}
]
});
}
};
I am using Java as my server side technology and for the report i am using Jasper Report.
Yogendra Singh
Sr. Programmer
Kintudesigns.com