Reportes con Jasper

It is easy to see why BBj®developers are jazzed aboutthe iReport Designer – nowthey can create and previewprofessional looking reports againsttheir live data with very little effort. TheiReport Designer Wizard steps thedeveloper through the report creationprocess to deliver useful and, in somecases, critical information. The next step,of course, is figuring out how to embedthe newly-created report into an existingapplication.

So, how do you use JasperReports inBBj?

The answer is simple and the focus ofthis article...use BBJasper – the newutility from BASIS that makes it easy tointegrate live reports into existing BBjapplications!BBJasper is a utility distributed in BBj 9.0and written in BBj as a CustomObject that embeds Java code to wrap andextend the Jasper API. This fullysupported, fully documented, and fullymodifiable utility delivers a very easy,yet very powerful mechanism to utilizeJasperReports in BBj. The BBJasperutility is comprised of three differentmodules or CustomObjects:

• BBJasperReport

• BBJasperViewerWindow

• BBJasperViewerControl

The BBJasperReport CustomObjectallows for creating, displaying, printing,and saving a report from within a GUI,CUI, or background BBj application.To create a report, this API requiresa .jrxml or .jasper file and a JDBCconnect string. The iReport Designerproduces the .jrxml/.jasper file andthe JDBC connect string provides theinformation necessary to acquire the data for the report. Specifying optionalreport parameters and a locale for reportcreation provide further report criteriaand localization. All of these inputscome together during the fill operation,which takes the design (.jasper or.jrxml) file, obtains the data via a JDBCconnection as specified in the connectstring, and applies the report parameterand localization. Voilà, a report is born!Figure 1 is a code sample that displaysa BBJasperReport in a BBj window.

BBJasper extends much-neededflexibility in printing the reports. Somecommon options and preferencesinclude printing to the server or client,displaying an optional dialog to allowthe user to change printers and printingpreferences, and the ability to save thereport in a myriad of formats includingHTML, XML, PDF, or XLS.

<Box>

iReport is a WYSIWYG visual report designer specifically designed forJasperReports. iReport gives administrators and report designers totalcontrol over the contents as well as the look and feel of every report. iReportallows users to build, test, and run reports from the desktop environment.iReport is available for Windows, Linux and Mac.

JasperReports is the world's most powerful and widely used embeddableopen source Java reporting library for report designers and developersthat can be used to generate reports in several formats including, amongstothers, PDF, HTML, Microsoft Excel, RTF and XML files. Java applicationscan use JasperReports to generate dynamic content.

BBJasperViewer is the component that allows JasperReports to beseamlessly embedded and viewed in a GUI BBj Thin Client.

</box>

The BBJasperViewerWindowCustomObject provides an API toview the report in a window and isimplemented as a BBjTopLevelWindow.As a result, all BBj API functions for aBBjTopLevelWindow are available onthis window. Some of the more popularfunctions include setting the positionof the window (x,y), the size of thewindow (width, height), and modificationflags (modal, modeless, close box,resizable, etc). Refer to the onlineBBj documentation for all availableBBjTopLevelWindow online functions.

The BBJasperViewerWindowcontains a BBJasperViewerControlsized to the window constraintsand is also accessible for furthercustomization as shown in Figure 2. TheBBJasperViewerControl CustomObjectoffers the ability to view the report in acontrol inside a pre-existing BBj window –a top level, child, or MDI. Because it isimplemented as a BBjControl, all BBjAPI functions for a BBjControl areavailable on this control, includingthe ID of the control, position of thecontrol (x,y), the size of the control(width, height), etc. (see the onlineBBj documentation for a full list ofavailable BBjControl functions). TheBBJasperViewerControl bestows thefinest level of control over the viewedreport. By default, it includes toolbuttonsthat enable users to save, print, reload,navigate pages, set viewing options,zoom in and out, and set the zoomratio. To go beyond these features,developers can even add customtoolbuttons for extended functionality.The truly adventurous at heart canaccess the underlying Java controlas a client object for absolute controlmanipulation.

Returning to the opening question,”How do you use JasperReportsin BBj?”, there is a more in-depthanswer than simply “use BBJasper.”JasperReports does not actually requirethe BBJasper utility so developers canalso use embedded Java and directcalls to the JasperReports Java API.This approach would take preciousresources such as time, money, andeffort that few in the IT industry canafford in these tough economic times.So the simple answer is the bestanswer. With very few resources,using the BBJasper utility unleashesthe power of JasperReports. So, turnon your imagination and jazz up yourapplication today!

FUENTES:

http://documentation.basis.com/advantage/v13-2009/jasperreports.pdf

https://www.basis.com/sites/basis.com/advantage/mag-v13n1/reportwriting.pdf

http://documentation.basis.com/advantage/v16-2012/12reportviewer.pdf

http://documentation.basis.com/advantage/v15-2011/11bbjasper.pdf