Discussion:
jasper report
mervz22
2005-09-29 09:31:11 UTC
Permalink
hi, is there any solution or idea about calling jasper report file on
thinlet application.

any suggestion, is really appreciated.

thx






------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
puicheng2004
2005-09-30 13:52:17 UTC
Permalink
Hi,

Yes, try this.

public void preview(){
try {
if (licence==null) { return; }
JasperPrint jPrint =
licenceService.getBusinessLicenceReport((BusinessLicence)licence);
new JasperViewer(jPrint, false).show();
} catch (Exception e) { e.printStackTrace();
}
}

And I use something like this on the server side to produce the
JasperPrint from .jasper.

private JasperPrint getJasperPrint(String jasperFile, JRDataSource
ds) throws Exception {
ClassPathResource cpr = new ClassPathResource(reportPath +
jasperFile + ".jasper");
JasperPrint jasperPrint = null;
try {
File reportFile = cpr.getFile();
JasperReport jasperReport =
(JasperReport)JRLoader.loadObject(reportFile.getPath());
jasperPrint = JasperFillManager.fillReport(jasperReport, null, ds );
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (JRException e) { e.fillInStackTrace();
} catch (Error e) { e.printStackTrace(); }
return jasperPrint;
}

It also requires jasperreports-0.6.4.jar, itext-0.96.jar and
jdt-compiler.jar for the jasperviewer to work.

Good luck.

Clifford
Post by mervz22
hi, is there any solution or idea about calling jasper report file on
thinlet application.
any suggestion, is really appreciated.
thx
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
mervz22
2005-10-01 01:27:07 UTC
Permalink
oy,hi tnx for your reply.i really appreciate this information, by
the way i am developing website that used thinlet,i would like to
know if .jrxml file would be possible to view on the web.using
thinlet.

my database is mysql.

http://www.kgo.de/ThinSQL.html

here the thinlet information that im using.

php connection to the mysql database.

i hope you are familiar with this site.

thank very much for your reply.

and i also tried your suggestion.

i hope you will give me some other information to this matter.

thx







------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
puicheng2004
2005-10-02 12:23:43 UTC
Permalink
Hi,

I don't use browser in my applications any more but I did that before
with .jasper. Here is the code:

public abstract class PdfServlet extends HttpServlet {

protected Map parameters;
protected File reportFile;
protected ServletContext context;
protected byte[] bytes = null;

public void service( HttpServletRequest request, HttpServletResponse
response )
throws IOException, ServletException {

context = this.getServletConfig().getServletContext();;

try {
execute(request);
} catch (JRException e) {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>JasperReports - Web Application Sample</title>");
out.println("<link rel=\"stylesheet\" type=\"text/css\"
href=\"../stylesheet.css\" title=\"Style\">");
out.println("</head>");

out.println("<body bgcolor=\"white\">");

out.println("<span class=\"bnew\">JasperReports encountered this
error :</span>");
out.println("<pre>");

e.printStackTrace(out);

out.println("</pre>");

out.println("</body>");
out.println("</html>");

return;
}

System.out.println("bytes = " + bytes.length);

if (bytes != null && bytes.length > 0) {
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
} else {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>JasperReports - Web Application Sample</title>");
out.println("<link rel=\"stylesheet\" type=\"text/css\"
href=\"../stylesheet.css\" title=\"Style\">");
out.println("</head>");

out.println("<body bgcolor=\"white\">");

out.println("<span class=\"bold\">Empty response.</span>");

out.println("</body>");
out.println("</html>");
}
}

protected abstract void execute( HttpServletRequest request )
throws JRException;
}

public class TitleSummaryReportServlet extends PdfServlet {

protected void execute(HttpServletRequest request) throws
JRException {

reportFile = new
File(context.getRealPath("/WEB-INF/classes/com/web/report/TitleListReport.jasper"));
parameters = new HashMap();
parameters.put("ReportTitle", "Movie Title Summary Report");
parameters.put("BaseDir", reportFile.getParentFile());

bytes = JasperRunManager.runReportToPdf ( reportFile.getPath(),
parameters,
new
TitleListDataSource(request) );
}
}

The idea is to generate a pdf on the server side that shows up in the
browser.

Clifford
Post by mervz22
oy,hi tnx for your reply.i really appreciate this information, by
the way i am developing website that used thinlet,i would like to
know if .jrxml file would be possible to view on the web.using
thinlet.
my database is mysql.
http://www.kgo.de/ThinSQL.html
here the thinlet information that im using.
php connection to the mysql database.
i hope you are familiar with this site.
thank very much for your reply.
and i also tried your suggestion.
i hope you will give me some other information to this matter.
thx
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
mervz22
2005-10-07 06:38:17 UTC
Permalink
do you have any sample application so that i can used.

i hope you will help me for my problem.

please.
again thank for the information








------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
puicheng2004
2005-10-11 02:00:06 UTC
Permalink
Hi,

Too busy in the last few days but I have quickly put some code
together. Pretty rough but should be sufficient for your purpose.
Please get it at http://demo.artsoft.ca/pdf.zip. Note that I have
hardcoded /pdf as the web context path in the applet. Please adjust as
appropriate.

Clifford
Post by mervz22
do you have any sample application so that i can used.
i hope you will help me for my problem.
please.
again thank for the information
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->

_________________________________________________________________
Thinlet Project Site | http://thinlet.com
Thinlet Addon Central | http://thinletplus.com
Thinlet World News Blog | http://thinletworld.com
Thinlet F.A.Q. | http://xul.sourceforge.net/thinfaq.html
Loading...