java - Twice click command button primefaces for download PDF -
my xhtml is
<h:form id="ibform"> <p:commandbutton value="yazdır" ajax="false" action="#{islemibitenlerbean.run_rpr('pdf')}" icon="ui-icon-print" immediate="true"/> </h:form>
backing bean (conversation scope)
public void run_rpr(string tip) throws ioexception, jrexception, classnotfoundexception, sqlexception { hashmap m = new hashmap(); m.put("belgeno", selectedbelge.getbelgeno()); reports.preparetreport(raporturu.pdf, "reports//rapor//onaybelgesi.jrxml", "onay belgesi", m); }
and preparetreport method is
public void preparetreport(raporturu tur, string filepath, string filename, hashmap jasperparameter) throws jrexception, ioexception, classnotfoundexception, sqlexception { connection connection; class.forname("oracle.jdbc.oracledriver"); connection = drivermanager.getconnection("jdbc:oracle:thin:@--------", "----", "******"); jasperreport jasperreport; jasperreport jasperreportsub; jasperprint print; facescontext faces = javax.faces.context.facescontext.getcurrentinstance(); httpservletresponse response = (httpservletresponse) faces.getexternalcontext().getresponse(); servletcontext servletcontext = (servletcontext) faces.getexternalcontext().getcontext(); string jrxmlfile = servletcontext.getrealpath("/") + filepath;//raporumuzun yolu jasperdesign jasperdesign = jrxmlloader.load(jrxmlfile); jasperreport = jaspercompilemanager.compilereport(jasperdesign); print = jasperfillmanager.fillreport(jasperreport, jasperparameter, connection); byte[] outdata = jasperexportmanager.exportreporttopdf(print); bytearrayoutputstream rrtreport = new bytearrayoutputstream(); servletoutputstream out = null; switch (tur) { case pdf: response.setcontenttype("application/pdf"); response.setheader("content-disposition", "attachment; filename=" + filename + ".pdf"); response.getoutputstream().write(jasperexportmanager.exportreporttopdf(print));//web sayfamızdan raporu çıkarttık faces.responsecomplete(); break; }
but have click twice download pdf. suggestion 1 click download?
Comments
Post a Comment