Run JasperReport on Client side ...

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

armin_kessler
Ebase User
Posts: 27
Joined: Sun Jan 08, 2012 2:39 am

Run JasperReport on Client side ...

#1

Postby armin_kessler » Mon Aug 05, 2013 4:34 pm

Hello all ...

I need to integrate JasperReport to my ebase Xi application, The report is generated OK , but the file is generated on the Server and I need that the report is stored on the Client PC. Is this possible ?

Here is my code:

Code: Select all

importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);
importPackage(Packages.net.sf.jasperreports.engine);
importPackage(Packages.net.sf.jasperreports.view);
importPackage(java.sql);
importPackage(java.util);

var l_Rep = "Documentos Por Cobrar";
var cual_jr = "P:\\ebase_Xi\\450\\UfsServer\\tomcat\\webapps\\ufs\\jr\\"+l_Rep+".jasper";
//var jasperDesign = new JRXmlLoader.load("P:\\ebase_Xi\\450\\UfsServer\\tomcat\\webapps\\ufs\\jr\\VENDEDORES.jrxml");
//var jasperReport = new JasperCompileManager.compileReport(jasperDesign);

var connection = null;
var exception = new Packages.java.sql.SQLException();
try
	 {
	  java.lang.Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
	  var l_URL = "jdbc:sybase:Tds:localhost:2800?ServiceName=italven90&CHARSET=utf8";
	  connection = DriverManager.getConnection(l_URL,"DBA","SQL");
	  connection.setAutoCommit(false);
	 }

catch (e)
{
 event.owner.addErrorMessage(e);  
 log (e);
}

var params = new HashMap();
params.put("p_NOMEMP", "PRUEBA C.A.");
params.put("p_NOMBRE_REPORTE", "Documentos x Cobrar");
params.put("p_RIFEMP", "J-11223344-5");
//params.put("p_FECHA", new Date());
params.put("p_CUALES_VDCOD", "");
var jasperPrint = new JasperFillManager.fillReport(cual_jr,
			            params , connection );

var l_dPdfs = "c:\\Pdfs";
if ( ! FileServices.existsFile(l_dPdfs) )
 FileServices.createNewDirectory(l_dPdfs);
   
JasperExportManager.exportReportToPdfFile(jasperPrint, l_dPdfs+"\\"+l_Rep+".pdf");
I am working with Ebase Xi 4.5 and read about Client script but do not understand to much.

Thank you all in advance.
0 x
Armin Kessler

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Aug 06, 2013 7:59 am

Armin,

From your code, it looks like you're just generating a PDF. So you could just display this to the user and they could then save it locally if they needed to - does this meet your requirement?

To do this, you need to create the PDF file in a directory which is accessible to the web application i.e. inside tomcat/webapps/ufs which is the root for the web application. For example create directory jasperReports in tomcat/webapps/ufs. Then change your code to:

Code: Select all

var l_dPdfs = FileServices.getWebAppRootFilePath() + "/jasperReports"; 
The getWebAppRootFilePath() method addresses the web application's root directory so using this means you don't have to hard code full path names.

You can then display your PDF to the user with something like:

Code: Select all

var fileName = "xxxxxxxx";
form.displayUrl("jasperReports/" + fileName);
Regards
Jon
0 x

armin_kessler
Ebase User
Posts: 27
Joined: Sun Jan 08, 2012 2:39 am

#3

Postby armin_kessler » Tue Aug 06, 2013 9:47 pm

Hello Jon,

All works OK as you indicated.

Thank you very much for your attention.

Armin
0 x
Armin Kessler


Who is online

Users browsing this forum: No registered users and 22 guests