Archive for Tháng Sáu, 2005

Using JasperReports JRPrintServiceExporter – Printing to a named printer

Muốn in JasperReport tới một máy in theo tên, không muốn user phải tự chọn? Thử tham khảo ở đây xem sao (chưa kiểm chứng):
http://www.multitask.com.au/people/dion/archives/000305.html

Với các câu lệnh giản lược sau đây như là một phần để tham khảo sau này :-) :

// check if there is a compiled report already, if not compile it File reportFile = new File("HelloWorld.jasper");if (!reportFile.exists()){       JasperCompileManager.compileReportToFile("HelloWorld.xml");}

// load the compiled reportJasperReport jasperReport = (JasperReport) JRLoader.loadObject(reportFile.getPath());

// set up a datasource, in thise case it's just a dummy one.JRDataSource ds = new JRXmlDataSource("HelloWorld.xml");

// fill the report, in this case no parameters and a dummy datasource JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), ds);

// create the print service exporter so that we can print to a named printerJRPrintServiceExporter exporter = new JRPrintServiceExporter();// set the report to printexporter.setParameter( JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint);

// tell the exporter to print 1 copy on A4 paperPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();aset.add(new Copies(1));aset.add(MediaSizeName.ISO_A4);exporter.setParameter( JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, aset);

// let the exporter know which printer we want to print onPrintServiceAttributeSet serviceAttributeSet = new HashPrintServiceAttributeSet();serviceAttributeSet.add(new PrinterName(args[1], null));exporter.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);

// print itexporter.exportReport();

Add comment Tháng Sáu 30, 2005

Another Chinese :-( Webblog about JasperReports

1 comment Tháng Sáu 30, 2005

jasper reports image expression

ImageExpression, một trong những thứ khó hiểu của JasperReports. Dùng nó như thế nào trong thực tế? Hãy xem thử một ví dụ sau:

Test thử nếu image có tồn tại không :

- “BaseDir” and “ReportCollecter” are passed to reports as parameters
CODE:





Add comment Tháng Sáu 30, 2005

Two or more jasper files in one pdf only

Có hai jasperreports và muốn combine thành 1 PDF? Chưa có giải pháp? Thử giải pháp này xem sao :
http://sourceforge.net/forum/forum.php?thread_id=1298338&forum_id=113529

Quote

If you are using net.sf.jasperreports.engine.export.JRPdfExporter to get the byte stream to send to the browser, you can call net.sf.jasperreports.engine.export.JRPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, list) where list is an ArrayList containing the JRPrints to be concatenated into one PDF. e.g.

List printList = new ArrayList();
printList.add(jrPrint1);
printList.add(jrPrint2);
ByteArrayOutputStream pdfOutput = new ByteArrayOutputStream();
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, printList);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfOutput);
exporter.exportReport();
byte[] results = pdfOutput.getBytes();

/Quote

Add comment Tháng Sáu 28, 2005

Yet, another framework : Wicket 1.0, web framework, released

Híc híc, học cái framework này chưa xong, đã nghe có framework khác hay hơn :-( . Chẳng thể nào có thời gian để xem xét thử xem thế nào, chỉ kịp đọc các discussion tại theserverside.com, với một số ý kiến xem ra rất hài lòng về anh chàng Wicket này (So với Tapestry).
Dù chẳng hiểu gì :-( , nhưng dù sao cũng nên note lại để lỡ sau này cần thì sao :-) .

Xem thêm tại trang chủ của Wicket : http://wicket.sourceforge.net/

Add comment Tháng Sáu 28, 2005

Project Dependencies Using Ant

Dùng để biên dịch, đóng gói, … thì thật là hữu ích … cho các project nhỏ, không có sub-project hay có sub-project nhưng đã được biên dịch trước đó :-) . Vấn đề đặt ra là làm sao giải quyết sự phụ thuộc của các sub-project để khi biên dịch và/hoặc phân phối, đóng gói… cho đúng?

Tác giả Joe Schmetzer đưa ra một giải pháp, xem ở đây :

http://www.exubero.com/ant/dependencies.html

Add comment Tháng Sáu 28, 2005

Using Hibernate queries with JasperReports

1. Bắt đầu từ trang này để hiểu cách dùng Hibernate với JasperReport
http://www.hibernate.org/79.html

2. Một trong những vấn đề gây đau đầu cho ai dùng JasperReport với Hibernate là phải làm gì để cải tiến performance của report và tránh OutOfMemory exceptions khi lượng dữ liệu quá lớn. John Ferguson Smart, một chuyên gia về J2EE đã có một bài rất hay trên web blog của ông ta về vấn đề này. Khi cần tham khảo, có thể xem tại đây: http://www.jroller.com/page/wakaleo/?anchor=using_hibernate_queries_with_jasperreports

Add comment Tháng Sáu 27, 2005

Generating online reports using JasperReports and WebSphere Studio

Add comment Tháng Sáu 27, 2005

An implementation of JasperReports data source provider interface

Đây là một ví dụ rất dễ hiểu và hữu ích về cách tạo một custom JasperReport datasource provider. Xem tại document của JasperAssistant : http://www.jasperassistant.com/docs/guide/ch03s02.html

Notes: Forum của JasperAssistant là một nơi rất hữu ích, tiếc rằng phải trả phí :-(

Sau đây là source code:

Mình cần cải tiến để có ví dụ dùng IBatis với ví dụ này.

import java.util.*;import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.data.*;

/*** Data source provider implementation that* provides a bean collection data source* containing instances of Person class.*/public class ExampleDataSourceProvider extends       JRAbstractBeanDataSourceProvider {

public ExampleDataSourceProvider() {   super(Person.class);}

public JRDataSource create(JasperReport report)       throws JRException {

   ArrayList collection = new ArrayList();   collection.add(new Person("Teodor", "Danciu"));   collection.add(new Person("Peter", "Severin"));   return new JRBeanCollectionDataSource(collection);}

public void dispose(JRDataSource dataSource)       throws JRException {   // nothing to dispose}

}

Add comment Tháng Sáu 27, 2005

Featuring the huge set of Java Open Sources

Đây là một nỗ lực combine về các opensource có trong Java, phân chia theo từng lĩnh vực, hạng mục. Dĩ nhiên không thể đầy đủ, nhưng có khá nhiều opensource Java quan trọng. Vì vậy có thể coi trang web này như một khởi điểm để tìm kiếm. Dĩ nhiên, không thể quên google :-) .

Xem Java opensource list combine ở đây: http://www.theopensourcery.com/javaopens.htm

Add comment Tháng Sáu 24, 2005

Previous Posts


 

Tháng Sáu 2005
T2 T3 T4 T5 T6 T7 CN
    Tháng 7 »
 12345
6789101112
13141516171819
20212223242526
27282930  

a

Blogroll

Grails

Groovy

Bài viết mới

Lưu trữ

RSS Jason Rudolph (GRails)

RSS Raible Designs

RSS CodeJacked blog