<?xml version="1.0"?>
<rss version="2.0"><channel><title>Blog: AgileTech - Ankur Gupta</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/?d=9</link><description>Blog: AgileTech - Ankur Gupta</description><language>en</language><item><title>How to resolve can't add a cell error  - While Exporting to excel in Jasperserver</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-resolve-cant-add-cell-error-while-exporting-excel-jasperserver/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:left;float:left;margin-bottom:1em;margin-right:1em;" rel="external nofollow"></a><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:left;float:left;margin-bottom:1em;margin-right:1em;" rel="external nofollow"></a>This is an error which you get while exporting the data from the <b>Jasperserver</b> in the <b>Excel Format.</b><br /><br /><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:left;float:left;margin-bottom:1em;margin-right:1em;" rel="external nofollow"></a><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:left;float:left;margin-bottom:1em;margin-right:1em;" rel="external nofollow"></a>Something of this sort<br /><br /><div style="clear:both;text-align:center;"></div><br /><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:right;float:right;margin-bottom:1em;margin-left:1em;" rel="external nofollow"></a><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:right;float:right;margin-bottom:1em;margin-left:1em;" rel="external nofollow"></a><br /><div style="clear:both;text-align:center;"></div><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:right;float:right;margin-bottom:1em;margin-left:1em;" rel="external nofollow"></a><a href="https://www.blogger.com/blogger.g?blogID=2279754227642197645" style="clear:right;float:right;margin-bottom:1em;margin-left:1em;" rel="external nofollow"></a><br /><div style="clear:both;text-align:center;"><a href="http://1.bp.blogspot.com/-pUPBuM1JEu4/VdLOg0ImrcI/AAAAAAAAHzM/pisrJx5k47g/s1600/image.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://1.bp.blogspot.com/-pUPBuM1JEu4/VdLOg0ImrcI/AAAAAAAAHzM/pisrJx5k47g/s400/image.png</span></a></div><br /><br />For resolving this you should check some of these errors:<br /><br />1. Number to string cast exception:<br />This means that a number is wrongly appended to a string in which wrongly cast number into string.<br />In order to fix this, you will have to use the command as<br /><br />new DecimalFormat("##,#0.00").format(number).toString()<br />This will cast your number into two decimal places with the thousand separator.<br /><br /><br />2. Another error that can be checked is of any other cast errors, or formatting of the data in the report.<br /><br /><br />Cheers!!<br /><br /><br /></div>]]></description><guid isPermaLink="false">306</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Setting mail account for Subscription of scheduled Jobs in JasperServer.</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/setting-mail-account-subscription-scheduled-jobs-jasperserver/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><br />I wanted to document the process from a long time but due to crunch of time I could not, but now I will like to explain the process in simple easy to follow steps.<br /><br />First of all I would like to give an idea to problem addressed in the blog, basically when a report runs as a daily status or daily count one need not run it manually it could be scheduled, but when the report is scheduled the export in desired form is exported on jasper server.<br /><br />But wait a minute do we really login and see what the results came as in the PDF, Excel etc. export, no we need not the problem is handled by mail subscription attached to the scheduler, which will automatically send the Exports to the subscribers on their email accounts and send a confirmation to the administrator.<br /><br />So lets cut the explanation and lets jump directly into how to do.<br /><br />Prerequisites -<br /><br />1. You should have working copy of JasperServer community/pro<br />2. You should have uploaded a report to the server<br />3. Choose you favourite text editor  (Windows(default) - Notepad/MacOS(default) - TextEdit)<br />4. Shut down the jasper server so that no sort of errors come in case of Editing/Saving documents.<br /><br />after following the above prerequisites now we head on to edit two files as follows.<br />Both these files will be found at the location <br />&lt;directory of Jasperserver on Disk&gt;/apache-tomcat/webapps/jasperserver/WEB-INF/<br /><br />1. <b>js.quartz.properties</b><br />   - Edit the file with the Text Editor<br />  <br /><blockquote>Change the portion of the document as (Please select your own server details I have used a gmail account )</blockquote></div><br /><blockquote><span style="color:#0000FF;">report.scheduler.mail.sender.host=</span><span style="color:#FF0000;">smtp.gmail.com</span><br /><span style="color:#0000FF;">report.scheduler.mail.sender.username=</span><span style="color:#FF0000;">testpanda@gmail.com</span><br /><span style="color:#0000FF;">report.scheduler.mail.sender.password=</span><span style="color:#FF0000;">password</span><br /><span style="color:#0000FF;">report.scheduler.mail.sender.from= </span><span style="color:#FF0000;">testpand@gmail.com</span><br /><span style="color:#0000FF;">report.scheduler.mail.sender.protocol= </span><span style="color:#FF0000;">smtp</span><br /><span style="color:#0000FF;">report.scheduler.mail.sender.port= </span><span style="color:#FF0000;">587</span></blockquote>  - Make the changes and save the file.<br /><br />2.   <b>applicationContext-report-scheduling.xml</b><br /><br />  -  Locate the bean reportSchedulerMailSender<br />  -  Locate the property javaMailProperties<br />  -  Do the changes as below - This will enable java to interact the smtp/startls authentication.      <br /><br />         <span style="color:#0000FF;">&lt;props&gt;</span><br /><span style="color:#0000FF;">                &lt;prop key="mail.smtp.auth"&gt;</span><span style="color:#FF0000;">true</span><span style="color:#0000FF;">&lt;/prop&gt;</span><br /><span style="color:#0000FF;"><span style="white-space:pre;">    </span>&lt;prop key="mail.smtp.starttls.enable"&gt;</span><span style="color:#FF0000;">true</span><span style="color:#0000FF;">&lt;/prop&gt;</span><br /><span style="color:#0000FF;">            &lt;/props&gt;</span><br /><div>  - Now save the document.</div><div><br /></div><div>Now the report subscription is ready for run, just start the Jasper Server and you are good to go.</div><div><br /></div><div>Cheers!!</div>]]></description><guid isPermaLink="false">237</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to export and import a  Jasper Server Repository on a remote system </title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-export-and-import-jasper-server-repository-remote-system/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">In this blog I have explained the steps to import and export the JasperServer Repository (In the steps below I have used a Remote Linux Machines accessed via windows machine)<br /><br />Before following the steps there would be requirement of following softwares-<br />1. WinSCP - To browse the files in Linux machine<br />2. PuTTy - To run the commands for export/import in the Linux shell<br /><div><br /></div><div><br /></div><div><br /></div><div><div>Steps Export reports in Jasper Reports</div><div><br /></div><div>1. Open PuTTy - and key in the IP address </div><div>2. Enter the username and password.</div><div>3. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic</div><div>4. Run the command  ./js-export.sh --uris &lt;Path of the Report&gt;  --output-dir &lt;Name of the folder to be exported&gt;</div><div>5. Open the WinSCP, and key in the  IP Address as well as the credentials and set the Protocol as SFTP .</div><div>6. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic</div><div>7. Drag and drop the folder created earlier to the local machine.</div></div><div><br /></div><div><br /></div><div><br /></div><div><div>Steps Import reports in Jasper Reports</div><div><br /></div><div>1. Open the WinSCP, and key in the  IP Address as well as the credentials and set the Protocol as SFTP .</div><div>2. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic</div><div>3. Drag and drop the folder downloaded with the report.</div><div>4. Now Open PuTTy - and key in the IP address </div><div>5. Enter the username and password.</div><div>6. Navigate to the folder /opt/jasperreport-server-5.0/buildomatic</div><div>7. Run the command  ./js-import.sh --input-dir &lt;name of the folder copied earlier&gt;</div></div><div><br /></div></div>]]></description><guid isPermaLink="false">228</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Fresh setup of Jasper Reports from scratch - For beginners</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/fresh-setup-jasper-reports-scratch-beginners/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">I have been thinking to compile  a document which outlines the complete process of installation and setup of the connection because generally when one starts they do not find much of material and they tend to get stuck on a trivial issue.<br /><br />So the post will have two portions, namely Installation and Setup.<br /><br /><div style="color:#4f81bd;font-family:'Trebuchet MS';font-size:16px;margin-bottom:14px;text-align:justify;"><b><i><br /></i></b></div><div style="color:#4f81bd;font-family:'Trebuchet MS';font-size:16px;margin-bottom:14px;text-align:justify;"><b><i>Installation </i></b></div><div style="margin-bottom:10px;min-height:19px;"><span style="font-family:Times, 'Times New Roman', serif;"><br /></span></div><div style="margin-bottom:10px;"><span style="font-family:Times, 'Times New Roman', serif;">This document will apprise you with the basic installation software, which would act as a prerequisite to run Jasper Report.</span></div><ol><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Java</b> –<br />As Jasper Reports is built on Java platform, so a proper installation of Java Development kit (jdk) is required. For official steps to install java one can refer to the link<br /><a href="https://www.java.com/en/download/help/windows_manual_download.xml%2520" rel="external nofollow"><span style="color:#0433ff;">https://www.java.com/en/download/help/windows_manual_download.xml</span></a> <br /></span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>iReport Designer</b> –<br />This is a third party Jasper Report designing software. iReport is the most popular visual designer tool for JasperReports Library and JasperReports Server (Business Intelligence).<br />The software can be downloaded in an exe run able format for windows machine, or other types of files as per the platform demands.<span style="color:#555555;"><br /><a href="http://community.jaspersoft.com/project/ireport-designer/releases" rel="external nofollow"><span style="color:#0433ff;">http://community.jaspersoft.com/project/ireport-designer/releases</span></a></span><br /><br /></span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Jasper Server</b> – <br />This is the software which acts as the interface which provides web touch to the reports rather makes it interactive in terms of external links and the drill downs<br />Below is the link from where the file could be downloaded.<br /><a href="http://community.jaspersoft.com/project/jasperreports-server/releases" rel="external nofollow"><span style="color:#0433ff;">http://community.jaspersoft.com/project/jasperreports-server/releases</span></a><br /><br /></span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Database  Server</b> -<br />The database server or the datasource which serves the purpose of feeding data to the report, in this projects case the setup was in the SQL Server 2008, which could vary from project to project .<br /> </span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Netbeans(Optional)</b> –</span></li></ol><br /><div style="margin-bottom:10px;margin-left:36px;"><span style="font-family:Times, 'Times New Roman', serif;">Netbeans is the development environment where in you could create sciptlets for customization purposes in the Jasper Reports. You could even go on to make customizations on the charts, where in you could use the <br /><a href="https://netbeans.org/downloads/" rel="external nofollow"><span style="color:#0433ff;">https://netbeans.org/downloads/</span></a> (Download the SE version)</span></div><div><br /></div><div><br /></div><div><br /></div><div><div style="color:#4f81bd;font-family:'Trebuchet MS';font-size:16px;margin-bottom:14px;text-align:justify;"><b><i>Setup and Connection</i></b></div><div style="margin-bottom:10px;min-height:19px;"><span style="font-family:Times, 'Times New Roman', serif;"><br /></span></div><div style="margin-bottom:10px;"><span style="font-family:Times, 'Times New Roman', serif;">Below are the steps for the setup, which would act as a prerequisite to run Jasper Report.</span></div><ol><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Java</b> –<br />Download and install java 7, please do mind not to install Java 8 as it is yet not supported by iReport. <br /></span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>iReport Designer</b> –<br />After installing the iReport, first thing you need to do is that the inclusion of java connector <br /><br /><span style="text-decoration:underline;"><b>Below is the process to include the Java Connector</b></span> <br /><br />i.  Download the Java connector for the Datasource, as we have the SQL Server datasource we need to download <br /><a href="http://www.java2s.com/Code/Jar/s/Downloadsqljdbc120jar.htm" rel="external nofollow"><span style="color:#0433ff;">http://www.java2s.com/Code/Jar/s/Downloadsqljdbc120jar.htm</span></a><br />For more info on the Connector follow the link -- <a href="https://docs.oracle.com/cd/E19501-01/819-3658/gcfoy/index.html" rel="external nofollow"><span style="color:#0433ff;">https://docs.oracle.com/cd/E19501-01/819-3658/gcfoy/index.html</span></a><br /><br />ii.  Navigate to Tools—&gt; Options  Classpath<br />And select the Add JAR, and then browse to the downloaded path of the connector <br /><br /><span style="text-decoration:underline;"><b>Now we  need to add a JDBC datasource</b></span><br /><br />i. Click on  the icon shown below on the top of the iReport window</span></li></ol><div><span style="font-family:'Trebuchet MS';"><span style="font-size:11px;"><br /></span></span></div><div style="clear:both;text-align:center;"><a href="http://2.bp.blogspot.com/-wcRnI36a7p8/VLO-87q65mI/AAAAAAAAGuI/bHn0xZYMAgw/s1600/xs1.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-wcRnI36a7p8/VLO-87q65mI/AAAAAAAAGuI/bHn0xZYMAgw/s1600/xs1.png</span></a></div><div style="clear:both;text-align:center;"><br /></div><div><span style="font-family:'Trebuchet MS';"><span style="font-size:11px;"><br /></span></span></div><div style="clear:both;text-align:center;"><br /></div><ol><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;">ii.  In the popup select New  Select The Datasource type as Database JDBC Connection<br /><br />iii. Now Enter the name of the connection, select the SQL Server driver and enter the name of the database in the url of the database, also key in your credentials, refer to the screenshot below</span><br /><br /><br /><a href="http://3.bp.blogspot.com/-gQJwYs6Argo/VLO_PzUbtWI/AAAAAAAAGuQ/KQjjPVKrXEI/s1600/xs1.png" style="font-family:Times;font-size:11px;margin-left:1em;margin-right:1em;text-align:center;" rel="external nofollow"><span>http://3.bp.blogspot.com/-gQJwYs6Argo/VLO_PzUbtWI/AAAAAAAAGuQ/KQjjPVKrXEI/s1600/xs1.png</span></a><br /><br /><span style="font-family:Times, 'Times New Roman', serif;">iv. Now test the connection, it will say the connection successful.<br /><br />We are now ready to create reports.<br /><br /></span></li><li style="margin:0px 0px 10px;"><span style="font-family:Times, 'Times New Roman', serif;"><b>Jasper Server</b> – <br />After installation in order to run Jasper Server open the browser and key in<br />localhost:8080/jasperserver<br />Then login using the credentials jasperadmin/jasperadmin<br /><br />Then setup the connection, righ click on the node and add a datasource<br />Enter the details below,  for the connector and setup the datasource.</span></li></ol><div style="clear:both;text-align:center;"><a href="http://1.bp.blogspot.com/-Pm6hS9xAazY/VLO_sfgCbcI/AAAAAAAAGuY/-i6nF7LCKDg/s1600/xs1.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://1.bp.blogspot.com/-Pm6hS9xAazY/VLO_sfgCbcI/AAAAAAAAGuY/-i6nF7LCKDg/s1600/xs1.png</span></a></div><div style="clear:both;text-align:center;"><br /></div><div style="clear:both;text-align:center;"><br /></div><div style="clear:both;text-align:center;"><br /></div><div style="clear:both;text-align:left;">The above steps are pretty basic and gives a fair idea as to what all basic necessities are there to process the installation and setup.</div><div><span style="font-family:'Trebuchet MS';"><span style="font-size:11px;"><br /></span></span></div></div></div>]]></description><guid isPermaLink="false">226</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Jasper Report- JRException: Image read failed</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/jasper-report-jrexception-image-read-failed/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div style="font-family:Verdana, Arial, sans-serif;"><div> This Exception comes generally when you try to export the report on Jasper Server in PDF Format, or from iReport, then due to the error in some of the image or all the images, which is producing the error.</div><div><br /></div><div>So to overcome this issue, you could set following properties of the image:</div><div><br /></div><div>1. Firstly you could simply setting the Cache Property to true<br />2. If that does not resolves the issue then you can set the property Error type to Blank</div><div><br /></div><div><br /></div><div>Hope that this helps.</div><div><br /></div><div>Cheers!!</div><div><br /></div><div style="font-size:11px;"><br /></div></div></div>]]></description><guid isPermaLink="false">218</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Jasper Reports Server's unique Source Code Management System</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/jasper-reports-servers-unique-source-code-management-system/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><br />Jasper Reports Server is basically a stand alone as well as embedded  reporting server which can be easily used for deploying the Jasper Reports. It provides a way to embed reports as well as analytics into a web or mobile application, as well as act a informational hub. <br /><br />Server is made to securely share and manage the Jasper reports and analytic views. The security feature is implemented via role management and user creation facility in Jasper Server.<br /><br />Now there are two ways you can use Jasper Server<br />1. Standalone application<br />2. Embed into services, or applications.<br /><br />Now moving on to the Source Code Management,<br /><br /><br /><h1 style="background-color:#FFFFFF;font-family:Arial, Verdana, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:19px;letter-spacing:-0.018em;margin:0.15em 1em 0.5em;">    What benefits do Source Code Management tools provide?<a href="http://sourceforge.net/apps/trac/sourceforge/wiki/What%20is%20Source%20Code%20Management#WhatbenefitsdoSourceCodeManagementtoolsprovide" style="border:none;color:#d7d7d7;font-size:0.8em;text-decoration:none;vertical-align:text-top;" title="Link to this section" rel="external nofollow"></a></h1><div style="background-color:#FFFFFF;font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:13px;">SCM tools help development teams in many ways:</div><ul style="background-color:#FFFFFF;font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:13px;padding-left:1em;"><li><strong>Collaboration:</strong> SCM tools prevent one user from accidentally overwriting the changes of another, allowing many developers to work on the same code without stepping one each other's toes.</li><li><strong>History:</strong> SCM tools track the complete development history of the software, including the exact changes which have occurred between releases and who made those changes.</li><li><strong>Release notes generation:</strong> Given the tracking of each change, the SCM can be used to generate notes for their software releases which accurately capture all of the changes included in the new release.</li><li><strong>Documentation and test management:</strong> SCM tools can be used to manage not just software source code, but also test suites and documentation for their software.</li><li><strong>Change notifications:</strong> To keep interested members of the team informed when changes occur to the source code.</li></ul><h1 style="background-color:#FFFFFF;font-family:Arial, Verdana, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:19px;letter-spacing:-0.018em;margin:0.15em 1em 0.5em;">   Who uses SCM tools?<a href="http://sourceforge.net/apps/trac/sourceforge/wiki/What%20is%20Source%20Code%20Management#WhousesSCMtools" style="border:none;color:#d7d7d7;font-size:0.8em;text-decoration:none;vertical-align:text-top;" title="Link to this section" rel="external nofollow"></a></h1><div style="background-color:#FFFFFF;font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:13px;">SCM tools are used by:</div><ul style="background-color:#FFFFFF;font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:13px;padding-left:1em;"><li>Project developers who are writing source code.</li><li>Project testers who need to download the very latest changes.</li><li>Advanced users who want to try out code that is not yet stable, mature or released.</li></ul><div><span style="font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:x-small;"><br /></span></div><div><span style="font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:x-small;">In JasperServer, the SCM is managed very intelligently, whenever you draw a report for viewing in then you always get a version of the report, so you are not really modifying what is there on server. </span><br /><span style="font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:x-small;"><br /></span><span style="font-family:Verdana, Arial, 'Bitstream Vera Sans', Helvetica, sans-serif;font-size:x-small;">Jasper Server always keeps the original content on the server and provides the user with an instance of the report which is directly stored in the Temp folder, and if you need the modified version you have created as the current version then you need to replace the report with the current version of the report, by right clicking on the report in the repository and then replacing the report.</span><br /><br />In light of this feature there is also a extreme care to be taken that which version is being replaced, because if once replaced the version of the report will be changes and it would be not possible to roll back the change.<br /><br />This feature is really very great when you need to work on the small modification in the report as you can draw a copy on the local system and work onto that until you get the desired modification as well as you can simultaneously compare the previous version of the report and if you get the desired changes executed you can replace the report and have a new version of the report.<br /><br />Hope this information helps you a lot!!<br />Cheers!!</div><br /></div>]]></description><guid isPermaLink="false">217</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Getting to know CrossTabs and how to implement in Jasper Reports</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/getting-know-crosstabs-and-how-implement-jasper-reports/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div dir="ltr" style="text-align:left;"><br /><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">CrossTabs are used for creating statistical view of a large sample data.</div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">They allow you to summarize a huge unorganized data to be organized in terms of commons between the data.</div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">Suppose You have a data containing two columns Year, Brand of the car sold</div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">Some thing like this </div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><b><br /></b></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><b>                                                          </b><br /><div style="clear:both;text-align:center;"><b><a href="http://2.bp.blogspot.com/-4e90CwiO2SA/VDZpU5Ds5sI/AAAAAAAABbs/nZj5qOc7p_4/s1600/inline%2B1.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-4e90CwiO2SA/VDZpU5Ds5sI/AAAAAAAABbs/nZj5qOc7p_4/s1600/inline%2B1.png</span></a></b></div><b> </b></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">Now if you have to tell the total sales of Audi  in 2000,2001,2002. It will be a long and tedious process, so to show it Schematically We can have Distinct Years and Distinct Car Brand Names for representing the data as they are the are the common attribute to the data .</div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;">So the statistical data will look like this</div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /><br /><br /><div style="clear:both;text-align:center;"><a href="http://2.bp.blogspot.com/-gogJCoOyu9M/VDZp4NEw0LI/AAAAAAAABb0/erZaQl7ZwiQ/s1600/Untitled.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-gogJCoOyu9M/VDZp4NEw0LI/AAAAAAAABb0/erZaQl7ZwiQ/s1600/Untitled.png</span></a></div><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"></div><div style="background-color:#FFFFFF;color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="background-color:#FFFFFF;"><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">In the table above you could easily determine the Number of car sold for either of the brands and in which specific year. Also The last column where the the two totals converge i.e. 16 shows you the total value of the sample. </div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">Now let me quickly move on to implementation of Cross Tab in Jasper Reports rather iReport.</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">For the tutorial I would be using the iReport v5.6.0</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;"><br /></div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">1. The data needs to be retrieved from a datasource (either JDBC/JavaBeans/Custom Datasource/Excel/CSV... etc)</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">2. For the demonstration purposes I will be using the Excel File as the datasource.</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">3. After defining the datasource, we need to add the CrossTab element from the pallete.</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">4. Pallete could be accessed, Window( Menu Bar) --&gt; Pallete, then from there the CrossTab could be found under the Report Elements.</div><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;">5. As soon as we drag the Pallete, we get an wizard as below,</div><div style="clear:both;color:#222222;font-family:arial, sans-serif;font-size:13px;text-align:center;"><br /></div><div style="clear:both;text-align:center;"><br /></div><ul style="color:#222222;font-family:arial, sans-serif;text-align:left;"><li><span style="font-size:13px;">    Select the datasource, if subdataset is created then we can use that or simply the main dataset could be used. For the tutorial Main dataset is used</span><a href="http://2.bp.blogspot.com/-Uh--glEgbBk/VA1mHS8o4yI/AAAAAAAABZY/eZ-kLBiGE2A/s1600/Untitled.png" style="clear:left;float:left;font-size:13px;margin-bottom:1em;margin-left:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-Uh--glEgbBk/VA1mHS8o4yI/AAAAAAAABZY/eZ-kLBiGE2A/s1600/Untitled.png</span></a><div style="clear:both;font-size:13px;text-align:center;"></div></li><li style="font-size:13px;">Next will appear the grouping criteria for the rows which in short means that which field(s) will come on the Rows of the Cross Tab. We need the car companies on as the rows which are unique.</li><li style="font-size:13px;"><a href="http://1.bp.blogspot.com/-rq51GELHo3Y/VA1nORLXryI/AAAAAAAABZk/bj0r840KX6k/s1600/Untitled.png" style="margin-left:1em;margin-right:1em;text-align:center;" rel="external nofollow"><span>http://1.bp.blogspot.com/-rq51GELHo3Y/VA1nORLXryI/AAAAAAAABZk/bj0r840KX6k/s1600/Untitled.png</span></a><br /></li><li style="font-size:13px;"><span style="font-size:x-small;">Next will appear the grouping criteria for the Columns which in short means that which field(s) will come on the Columns  of the Cross Tab. We need the Years on as the rows which are unique<br /><a href="http://4.bp.blogspot.com/-rPzHjB4qM1A/VA1n3VUAvNI/AAAAAAAABZs/Kwa-ZSip2Jk/s1600/Untitled.png" style="font-size:13px;margin-left:1em;margin-right:1em;text-align:center;" rel="external nofollow"><span>http://4.bp.blogspot.com/-rPzHjB4qM1A/VA1n3VUAvNI/AAAAAAAABZs/Kwa-ZSip2Jk/s1600/Untitled.png</span></a></span></li><li style="font-size:13px;"><span style="font-size:x-small;">Next will be the Measure or the count of the value in particular grid.<br />Which in our case would be the number of cars of a particular company in a particular Year<br /><br /><a href="http://2.bp.blogspot.com/-yTFxTVB2G7A/VA1odVmVpeI/AAAAAAAABZ4/ds1Nknc3juk/s1600/Untitled.png" style="font-family:'Times New Roman';font-size:medium;margin-left:1em;margin-right:1em;text-align:center;" rel="external nofollow"><span>http://2.bp.blogspot.com/-yTFxTVB2G7A/VA1odVmVpeI/AAAAAAAABZ4/ds1Nknc3juk/s1600/Untitled.png</span></a></span></li><li style="font-size:13px;"><span style="font-size:x-small;">Then will come the window to select the layout of the crosstab, this means here we can customize the looks of the cross tab by defining the colors and which columns to show/hide.<br /><br /><a href="http://4.bp.blogspot.com/-gmBUloR-WcY/VA1pE6dmdNI/AAAAAAAABaA/FVHfoHxA6Y0/s1600/Untitled.png" style="font-family:'Times New Roman';font-size:medium;margin-left:1em;margin-right:1em;text-align:center;" rel="external nofollow"><span>http://4.bp.blogspot.com/-gmBUloR-WcY/VA1pE6dmdNI/AAAAAAAABaA/FVHfoHxA6Y0/s1600/Untitled.png</span></a><br /><br /><br /><br />6. Now this brings to the completion of the crosstab, now we could see that a tab at the bottom left corner appeared showing the name of the Crosstab, as Crosstab 1. There we could see the columns and design of the Crosstab.</span><div style="clear:both;text-align:center;"><a href="http://3.bp.blogspot.com/-53N_HsUh4zY/VA1psnzwgGI/AAAAAAAABaM/HZFLCfstf8I/s1600/Untitled.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://3.bp.blogspot.com/-53N_HsUh4zY/VA1psnzwgGI/AAAAAAAABaM/HZFLCfstf8I/s1600/Untitled.png</span></a></div><br /><br />7. Now a very critical point is placement of the crosstab, this should be really placed in a report band wherein the data is calculated already and then is to be shown in crosstab, the most favorable band to show the CrossTab is Summary band, else it will throw an<i><b> Error Incrementing crosstab dataset/ Crosstab already been processed.<br /><br />Now to Explain the exception<br /></b></i><blockquote style="background:rgb(238,238,238);border:0px;color:#000000;font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;font-size:14px;font-style:normal;font-weight:normal;line-height:17.8048000335693px;margin:0px 0px 10px;padding:10px 10px 1px;vertical-align:baseline;"><i><b></b></i><div style="background:transparent;border:0px;clear:both;margin-bottom:1em;padding:0px;vertical-align:baseline;"><i><b>What "Crosstab data has already been processed" exception means?</b></i></div><i><b></b></i><div style="background:transparent;border:0px;clear:both;margin-bottom:1em;padding:0px;vertical-align:baseline;"><i><b>This exception is thrown if more data is added to the crosstab dataset after the crosstab has already been rendered.<br />This usually happens when a crosstab element is linked to the main dataset of the report (does not use a subdataset run) and the resetType attribute of the crosstab dataset does not match the place where the crosstab is rendered.<br />Crosstabs are special components that display aggregated data. And when they are linked to the main dataset of the report, you simply cannot put them in the detail section, because there is no data to aggregate from a single record.<br />Such crosstabs could only reside on a group footer or on the summary section of the report and have the appropriate resetType value, so that their dataset is initialized each time after they are rendered.<br />If you still think you need to render one crosstab for each detail in the master document, then almost certainly this crosstab should be linked to a subdataset and not to the main dataset of the report.</b></i></div><i><b></b></i></blockquote><i><b></b></i></li></ul></div><div style="background-size:initial;border:0px;clear:both;color:#000000;font-family:Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;font-size:14px;font-style:normal;font-weight:normal;line-height:17.8048000335693px;margin-bottom:1em;padding:0px;vertical-align:baseline;"><br /></div><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><br /></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><br /></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><a href="https://drive.google.com/file/d/0B4yFyF_EORB_am5FV3BUbEZ4eTQ/edit?usp=sharing" rel="external nofollow">Download the tutorial JRXML here.</a></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><br /></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i>How to set up the tutorial Report:</i></b></span></div><div style="background-color:#FFFFFF;"><br /></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i>1. Unzip the file downloaded from the above link.</i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i>2. The Zip contains sampleds.xls, CrossTabTut.jrxml and TestRun.pdf<br />3. Open iReport and set up the Excel Datasource using the sampleds.xls</i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i>4. Then open the sample report and its ready to run.</i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><br /></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i><br /></i></b></span></div><div style="background-color:#FFFFFF;"><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><b><i>Hope that this helps!!<br />Cheers!!</i></b></span></div><div style="background-color:#FFFFFF;"><br /><br /><span style="color:#222222;font-family:arial, sans-serif;font-size:x-small;"><br /></span><br /><br /><div style="color:#222222;font-family:arial, sans-serif;font-size:13px;"></div></div></div><br /><ins style="height:280px;width:336px;"></ins>]]></description><guid isPermaLink="false">211</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to display the Username of the user who logged into JasperServer</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-display-username-user-who-logged-jasperserver/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div style="background-color:#FFFFFF;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><span style="font-size:small;"><span style="font-family:Arial;">Many a times we require the name of the person who logged into the Jasper Server and according to this information we are able to show/hide the elements on report, or simpley to log the user name we can use it.</span></span></div><div style="background-color:#FFFFFF;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><span style="font-size:small;"><span style="font-family:Arial;"><br /></span></span></div><div style="background-color:#FFFFFF;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><span style="font-size:small;"><span style="font-family:Arial;">So how to achieve this ? </span></span></div><div style="background-color:#FFFFFF;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><span style="font-size:small;"><span style="font-family:Arial;"><br /></span></span><br /><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="font-size:small;"><span style="font-family:Arial;">We can create parameters in our report, with a specific name and datatype. Then these parameters will be automatically filled when the report is executed by JasperReports Server.</span></span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="font-size:small;"><span style="font-family:Arial;"><b>LoggedInUsername</b> (java.lang.String), with no default value. Then, we can use $P{LoggedInUsername} in a text field, in a query, in a printWhenExpression, etc ...</span></span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="font-size:small;"><span style="font-family:Arial;">This is a built in parameter which gets filled with the User Details when report is run on Jasper Serve<span style="color:#666666;">r.</span></span></span></div></div><div style="background-color:#FFFFFF;color:#666666;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"></div><div style="background-color:#FFFFFF;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><strong><span style="font-size:small;"><span style="font-family:Arial;">Note that the report if run in iReport, would get a null value. So for the correct results it is necessary that we deploy the report onto JasperServer.</span></span></strong></div><div style="background-color:#FFFFFF;color:#666666;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><br /></div><div style="background-color:#FFFFFF;color:#666666;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><br /></div><div style="background-color:#FFFFFF;color:#666666;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><div style="margin-bottom:0.0001pt;"><br /></div><table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse;border:none;"> <tbody><tr>  <td style="border-bottom:solid #9BBB59 1pt;border-left:none;border-right:none;border-top:solid #9BBB59 1pt;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div align="center" style="line-height:13.5pt;margin-bottom:0in;text-align:center;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;">Parameter Name</span></b><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;"></span></b><p><b></b></p><b></b></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border-left:none;border-right:none;border-top:solid #9BBB59 1pt;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div align="center" style="line-height:13.5pt;margin-bottom:0in;text-align:center;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;">Type</span></b><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;"></span></b><p><b></b></p><b></b></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border-left:none;border-right:none;border-top:solid #9BBB59 1pt;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div align="center" style="line-height:13.5pt;margin-bottom:0in;text-align:center;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;">Notes</span></b><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:10.5pt;"></span></b><p><b></b></p><b></b></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border-left:none;border-right:none;border-top:solid #9BBB59 1pt;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUser</span></b><p><b></b></p><b></b></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">User</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Not usable in query  input control,<br />   but is used as parameter to report</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUsername</span></b><p><b></b></p><b></b></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">String</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Of logged in user</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserFullName</span></b><p><b></b></p><b></b></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">String</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Of logged in user</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserEmailAddress</span></b><p><b></b></p><b></b></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">String</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Of logged in user</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserEnabled</span></b><p><b></b></p><b></b></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Boolean</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Is logged in user  enabled?</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserExternallyDefined</span></b><p><b></b></p><b></b></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Boolean</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Is logged in user  externally defined?<br />   ie. authenticated externally</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserTenantId</span></b><p><b></b></p><b></b></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">String</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Of logged in user.  Only relevant in</span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"> </span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"><br />  Pro/Enterprise.</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserRoles</span></b><p><b></b></p><b></b></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Collection&lt;string&gt;</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Current set of roles  of logged in user.</span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"> </span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"><br />  Useful for $X parameter</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserAttributes</span></b><p><b></b></p><b></b></div></td>  <td nowrap="nowrap" style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Map&lt;string,  string&gt;</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Not usable in query  input control, but is</span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"> </span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"><br />  used as parameter to report.<br />   Empty map if no attributes</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserAttributeNames</span></b><p><b></b></p><b></b></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Collection&lt;string&gt;</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">User profile  attribute names. Useful for<br />   $X parameters. Empty collection if no</span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"> </span><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;"><br />  attributes</span><p></p></div></td>  <td style="border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserAttributeValues</span></b><p><b></b></p><b></b></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Collection</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">-</span><p></p></div></td>  <td style="background:#E6EED5;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr><tr>  <td nowrap="nowrap" style="border-bottom:solid #9BBB59 1pt;border:none;padding:0in 5.4pt 0in 5.4pt;width:41.02%;" valign="top" width="41%"><div style="line-height:13.5pt;margin-bottom:0in;"><b><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">LoggedInUserAttribute_&lt;attribute  name&gt;</span></b><p><b></b></p><b></b></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border:none;padding:0in 5.4pt 0in 5.4pt;width:19.34%;" valign="top" width="19%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">String</span><p></p></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border:none;padding:0in 5.4pt 0in 5.4pt;width:37.2%;" valign="top" width="37%"><div style="line-height:13.5pt;margin-bottom:0in;"><span style="color:#556677;font-family:Arial, 'sans-serif';font-size:9pt;">Attribute value for  matched attribute name (like "att1") on the user. Empty string  if no match. Only provided if defined in a query or as a  report parameter.</span><p></p></div></td>  <td style="border-bottom:solid #9BBB59 1pt;border:none;padding:0in 5.4pt 0in 5.4pt;width:2.44%;" valign="top" width="2%"></td> </tr></tbody></table></div><div style="background-color:#FFFFFF;color:#666666;font-family:Verdana, Arial, Calibri, sans-serif;font-size:11px;"><br /></div><div style="text-align:left;">Using the above parameters we could easily get various important information which could help in defining the roles. </div><div style="text-align:left;"><br /></div><div style="text-align:left;">Happy Coding.!!</div></div>]]></description><guid isPermaLink="false">177</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Using Styles in Jasper Reports</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/using-styles-jasper-reports/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">We have been accustomed to use style sheets or CSS in our HTML codes, parallel to that we can use Styles in Jasper Reports also. It provides same utilities like conditional, non -conditional and could be applied on  any element in the Report.<br><br>Now how to create styles, there are two methods basically:<br>1. External Style Sheet (jrtx file)<br>2. Declaring Internal Styles in the report itself.<br><br>The advantages of using external Style sheet is that it provides modularity and re-usability of the style over large number of reports using similar kind of styles. On the other hand, Internal styles would only contains the styles definitions for a particular report.<br><br>How to apply styles in the reports(iReport).<br><br>1. Locate the Styles node in the Report Inspector.<br>2. Right Click on the node and add a new Style<br>3. Then you could define the properties of the Style in the in the properties pane. Properties like background-color,forecolor, outline,.. etc/<br>4. You could even click on the Style and add a conditional Style and define conditional styles, like alternate coloring and much more.<br>5. After defining the styles now in the application part, locate the element onto which you want to apply the style.<br>6. Select the particular style in the property called <b>Style(could be found in the properties pane) </b>of the Element.<br><br>I have created a simple tutorial video demonstrating the Styles in Jasper Reports. 
<div class="ipsEmbeddedVideo" contenteditable="false"><div><iframe width="200" height="113" src="https://www.youtube-nocookie.com/embed/Uf3g_IyrliQ?feature=oembed" frameborder="0" allowfullscreen="" title="How to use styles in Jasper Reports" loading="lazy"></iframe></div></div><br><br>Download the sample demonstrated in the video tutorial from <a href="https://drive.google.com/file/d/0B4yFyF_EORB_cFh6dG1wN2lTQlU/edit?usp=sharing" rel="external nofollow">here</a>. The ZIP file contains :<br>1. The JRXML File<br>2. The jrtx Style.<br><br>The Sample uses the Sample database so no need to worry about the datasource.<br><br>Happy Coding.</div>]]></description><guid isPermaLink="false">176</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Cascading Parameters in Jasper Reports</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/cascading-parameters-jasper-reports-0/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">Cascading, what does one mean by saying cascading, literally it means  anything   that   resembles   a   waterfall or  especially seeming to flow. Now where to implement this in Jasper Reports?    <br><div><br></div><div>Right, it could be used in parameters, or rather the filters which are dependent on each other. You can find these kind of filters in online shopping websites, wherein we can choose on various filters like if we want to buy the laptop first filter would be Laptop next filter would be the company chosen among the companies which sell Laptops, and then we chose for the specifications like processor,ram etc. each have separate filters but the boundaries of the parameter depends on the previous parameter.<br><div style="text-align:left;"><br></div><div style="text-align:left;">Before getting into the setup of Cascading Parameters in Jasper Report there are few things which we need to know before hand - </div><div style="text-align:left;">Usage of   <b>  $X{IN, feild, parameter}</b> in the SQL Query used in the Where clause, which filters the data based on the selection. Let me go one by one in explaining the components</div><div style="text-align:left;"><b>field </b>- Now this is the field in the database upon which the find will be done</div><div style="text-align:left;"><b>parameter </b>- Now this is the parameter selected by user and will be queried or looked in the field. This enable for multi select also in the parameters.</div><div style="text-align:left;"><br></div><div style="text-align:left;">Now in  order to achieve this in Jasper Reports we need to follow few steps.</div><div style="text-align:left;"></div><br><ol style="text-align:left;"><li>First of all you need to design a Jasper Report and identify the parameters to be cascaded</li><li>Then we need to define the expression for parameters,  and mind one thing that each of the parameter need to be of type java.util.collection if you want to enable multi- select.</li><li>Next and very important thing is that the cascading parameters could not be tested in iReport / JasperSoft Studio, this  needs to be deployed on Jasper Server in order to check the correct functionality. Though could be run in iReport or JasperReports with default values hardcoded.</li></ol><br><br><br>I have created a working sample which could be simply deployed, and checked for the functionality and working.<br>The Zip file could be downloaded from here  - <a href="https://drive.google.com/file/d/0B4yFyF_EORB_VlZULThDN3V2MVk/edit?usp=sharing" rel="external nofollow">LINK TO ZIP FILE</a><br><br>The Zip file contains<br>1. Cascade Parameter Report (JRXML File)<br>2. SQL DUMP, could be extracted using MySQL or any other tool<br>3. Table Creation Script in a notepad file, this will allow you to create the require table in the database.<br><br>For setting up the sample report you need to-<br>1. Create a schema in you database and create the table using the script command<br>2. Then run the JRXML file using iReport/Jaspersoft Studio<br>3. Then set the datasource referring to Persons table in the database.<br>4. Then deploy the JRXML  on the Jasper Server, and set the datasource and input controls. Do remember the names of the parameters used in the report should exactly match the input controls declared on the Jasper Server.<br><br>If you miss on some step then you could follow a YouTube video of mine which  will serve as a tutorial.<br>Below is the video where in you could see all the steps.<br><br><br><iframe allowfullscreen="" frameborder="0" height="270" width="480" src="https://www.youtube.com/embed/N7pBJktoSt8" loading="lazy"></iframe><br><br>Please put your views or questions or suggestions below, I will be more than happy to hear them.Happy Coding!!</div></div>]]></description><guid isPermaLink="false">173</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>All you want to know about Scriptlets!!</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/all-you-want-know-about-scriptlets/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div><div style="clear:both;text-align:center;"><a href="http://2.bp.blogspot.com/-UXQ4wo62gCg/Us_5SaTaZsI/AAAAAAAAAhA/qE9CIjUBZRs/s1600/Figure1-JasperSoft+Studio.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><br /></a></div>First question which comes to mind after coming across thisword Scriptlet is that does it have any relationships with scripts, if yes thenwhat scripts, the answer  to thisquestion is No it does not have any relation with scripts.    Scriptlets basically act as an interfacebetween the Jasper Reports and Java. It provides much of flexibility to thereporting as now we can introduce user defined functions.</div><div><br /></div><div>Scriptlet is nothing but a java class which is extended witheither <br /><b>1</b>. <b><span style="background-color:#FFFFFF;">net.sf.jasperreports.engine. JRAbstractScriptlet<br />2. net.sf.jasperreports.engine.JRDefaultScriptlet. <br /><br /></span></b><span style="background-color:#FFFFFF;">Now we need to identify which class we need toextend based upon the usage<b>, JRAbstractSriptlet c</b></span><span style="background-color:#FFFFFF;">ontains anumber of abstract methods that must be overridden in every implementation, developermust implement all the abstract methods whereas <b>JRDefaultScriptlet</b> contains default empty implementations of everymethod in JRAbstractScriptlet, a developer is only required to implement thosemethods he/she needs for their project.</span><p></p></div><div><br /></div><div><span style="background-color:#FFFFFF;">Now following listed are the methods that will be called bythe report engine at the appropriate time, during report filling phase.</span></div><div><span style="background-color:#FFFFFF;"><br /></span></div><table border="1" cellpadding="0" cellspacing="0" style="background:#F7F7F7;border-collapse:collapse;border:none;margin-left:59pt;width:467px;"> <tbody><tr>  <td style="border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void beforeReportInit()<p></p></div></td>  <td style="border-left:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called before report initialization.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void afterReportInit()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called after report initialization.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void beforePageInit()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called before each page is initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void afterPageInit()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called after each page is initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void beforeColumnInit()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called before each column is initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void afterColumnInit()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called after each column is initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void beforeGroupInit(String groupName)<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called before the group specified in the parameter is  initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void afterGroupInit(String groupName)<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called after the group specified in the parameter is  initialized.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void beforeDetailEval()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called before each record in the detail section of the  report is evaluated.<p></p></div></td> </tr><tr>  <td style="border-top:none;border:solid #D6D6D6 1pt;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">public void afterDetailEval()<p></p></div></td>  <td style="border-bottom:solid #D6D6D6 1pt;border-left:none;border-right:solid #D6D6D6 1pt;border-top:none;padding:3.15pt 3.15pt 3.15pt 3.15pt;"><div style="margin-bottom:0.0001pt;">Called after each record in the detail section of the  report is evaluated.<p></p></div></td> </tr></tbody></table><div><br /></div><div><br /></div><div></div><div><br /></div><div>Except these we can also use User defined custom functions,I have already posted about them in my previous post here is the link- </div><div><a href="http://mindfirejavaexperts.wordpress.com/2014/01/10/how-to-add-user-defined-function-in-ireport/" rel="external nofollow">http://ankurthetechie.blogspot.in/2013/12/jasperScriptletIntegration.html</a></div><div><br /></div><div>Few important facts which need to be kept in mind usingscriptlets are-</div><div style="text-indent:0px;"><ol style="text-align:left;"><li><span style="text-indent:-0.25in;">When we do a System.out.println in any of thefunction then it does not directly print in the report, many a times peoplehave some misconception but to remind System.out.println</span><span style="text-indent:-0.25in;">  </span><span style="text-indent:-0.25in;">is a console command and prints the value inthe Report console, that is called the Report output window.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="font-family:Arial, sans-serif;font-size:9pt;line-height:115%;text-indent:-0.25in;">These functions are fired whenthe Jasper Print object is created, and it is created when a JRXML runs.</span></li></ol></div><br /><div><br /></div><div>Now after creating our scriptlet classes and packaging  it into a jar file we are ready to use it inour Jasper Report created either in iReport or JasperSoft Studio.</div><div><br /></div><div>Follow the following steps to implement scriptlets in iReport</div><div></div><ol style="text-align:left;"><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Add the Scriptlet jar file in the classpath byclicking on the Tools(Menu Bar) </span><span style="font-family:Wingdings;text-indent:-0.25in;">à</span><span style="text-indent:-0.25in;">Options </span><span style="font-family:Wingdings;text-indent:-0.25in;">à</span><span style="text-indent:-0.25in;">Classpath Tab</span><span style="text-indent:-0.25in;">  </span><span style="text-indent:-0.25in;">and add the Jar file here.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Locate the Report Inspector Window</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">There is a node called Scriptlet, expand thenode and we could see REPORT</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">You can create a another scriptlet label byright clicking the scriptlet label and then select Add</span></li><li><span style="text-indent:-0.25in;">Now locate the new element called Scriptlet1under the node SCRIPTLET.<b> (Check Fig-1)</b></span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Navigate to the properties of the Scriptlet1there could be seen Name, Scriptlet Class and Description.</span></li><li><span style="text-indent:-0.25in;">Now youcan enter the desired name for the scriptlet.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Scriptlet Class is the fully qualified path of the scriptlet class in the JAR File.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Description is for the describing the role ofthe scriptlet <b>( Check Fig-2)<br /> </b></span></li></ol><div><div style="clear:both;text-align:center;"><a href="http://4.bp.blogspot.com/-wFFhQWmYIMc/Us_69LMP4XI/AAAAAAAAAhM/PMzqd7DSRvw/s1600/Figure1-JasperSoft+Studio.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://4.bp.blogspot.com/-wFFhQWmYIMc/Us_69LMP4XI/AAAAAAAAAhM/PMzqd7DSRvw/s1600/Figure1-JasperSoft+Studio.png</span></a></div><br /><br /><br /></div><div>Follow the following steps to implement scriptlets in JasperSoft Studio</div><div></div><ol style="text-align:left;"><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Add the Scriptlet jar file in the classpath byclicking on the Project(Menu Bar) </span><span style="font-family:Wingdings;text-indent:-0.25in;">à</span><span style="text-indent:-0.25in;">Properties, then select Java Build Path and external JAR File.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Locate the Outline window</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">There is a node called Scriptlet, expand thenode and we could see REPORT_SCRIPTLET</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">You can create a another scriptlet label byright clicking the scriptlet label and then select Create Scriptlet <b>(As in Fig 1)</b></span></li><li><span style="text-indent:-0.25in;">Now locate the new element called Scriptlet_1under the node SCRIPTLETS.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Navigate to the properties of the Scriptlet_1there could be seen Name, Class and Description.</span></li><li><span style="text-indent:-0.25in;">Now you can enter the desired name for thescriptlet.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Class is the fully qualified path of thescriptlet class in the JAR File.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Description is for the describing the role ofthe scriptlet.</span> <b> (As in Fig 2)</b></li></ol><br /><div><span></span><span></span><br /></div><div><a href="http://2.bp.blogspot.com/-UXQ4wo62gCg/Us_5SaTaZsI/AAAAAAAAAhA/qE9CIjUBZRs/s1600/Figure1-JasperSoft+Studio.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-UXQ4wo62gCg/Us_5SaTaZsI/AAAAAAAAAhA/qE9CIjUBZRs/s1600/Figure1-JasperSoft+Studio.png</span></a></div><div><br /></div><div><br /></div><div>Now until now we have success fully linked the scriptlet JARwith the iReport/JasperSoft Studio, now we need to understand that how can itbe used in the report in order to get the desired outputs from the scriptlet orbasically from the JAVA end.</div><div><br /></div><div>To use the scriptlet functions in either iReport/ JasperSoftStudio following are the steps:</div><div></div><ol style="text-align:left;"><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">When we successfully create a new scriptletunder the scriptlet node, and define the properties of the scriptlet wecould  see a new parameter formed underthe Parameter node.</span></li><li><span style="font-size:7pt;text-indent:-0.25in;"> </span><span style="text-indent:-0.25in;">Locate the scriptlet parameter, you can find theparameter as by default it is named as</span><span style="text-indent:-0.25in;"> ( {name of the scriptletdefined}_SCRIPTLET )</span></li><li><span style="text-indent:-0.25in;">Then wherever you want to use any function ofthe scriptlet, you just need to use as:<br /><span style="text-indent:-0.25in;">( {name of the scriptlet defined}_SCRIPTLET ).function Name</span></span></li></ol><br /><div><br /></div><div>That is all we need to implement to use scriptlet in JasperReports, hope that the above description and methodology helps to graspimportant points.</div><div><br />Here is a sample using the sample database, you can try the above customization too.<br /><br />                                           <a href="https://drive.google.com/file/d/0B4yFyF_EORB_cGhrQ1ZzMDh6eGc/edit?usp=sharing" rel="external nofollow"> ======SAMPLE========</a><br /><br /><br /></div><div><span style="background:#FFFFFF;color:#222222;">Hope this clears your doubt for this topic. Still if you faceany issues or problems then you can add a comment below.</span><p></p></div><div><span style="background:#FFFFFF;color:#222222;"><br /></span></div><br /><div>Happy Coding!!</div></div>]]></description><guid isPermaLink="false">165</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to set datasource in iReport using a JRDatasource Provider as well as custom JRDataSource - Along with sample and Video Tutorial</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-set-datasource-ireport-using-jrdatasource-provider-well-custom-jrdatasource-along-sample/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">JRDataSource is   interface that  represents the abstract representation of a JasperReports data source. All data source types must implement this interface. <br><div><br></div><div>We could create   JRDatasource using java code, but there is a stipulation that the class made as the datasource needs to implement JRDataSource interface.</div><div><br></div><div>Now, in this article I will talk about:</div><div>1. Setting the datasource using custom JRDataSource.</div><div>2. Setting the datasource using JRDataSourceProvider.</div><div><br></div><div>To start with, </div><div><b>Setting the datasource using custom JRDataSource.</b></div><div>The prerequisites for the creating a custom datasource are:</div><div>1. JRDataSource</div><div>2. Factory class setting the JRDataSource.</div><div><br></div><div><br></div><div><br></div><div><b>Setting the datasource using JRDataSourceProvider</b></div><div><div>The prerequisites for the creating a custom datasource are:</div><div>1. JRDataSource</div></div><div>2. JRDataSourceProvider implemented class.</div><div><br></div><div><br></div><div>For showing setting of each of the methods I have created a youtube video.<br>                                                
<div class="ipsEmbeddedVideo" contenteditable="false"><div><iframe width="200" height="113" src="https://www.youtube-nocookie.com/embed/aCBRMm5_vbQ?feature=oembed" frameborder="0" allowfullscreen="" title="How to set JRDatasourceProvider and custom JRDatasource as datasource in iReport along with sample" loading="lazy"></iframe></div></div><br><br>In the sample I have created, what I intend to do is that I want to know the names, is directory(boolean true/false) and the size on disk, of the folder whose path is passed in the constructor of the datasource. Now in my datasource I have 3 columns <b>NAME</b>, <b>SIZE</b> and <b>IS_DIRECTORY.</b></div><div><br></div><div>In both the cases we need to create a JRDatasource class .. that is the class which implements JRDataSource, so in the sample it looks like this </div><div><br></div><div><blockquote style="background-color:#E6E6FA;width:400px;">/** <br>* JR DataSource Class<br>* @author Ankur Gupta<br>*/<br>public class JRFileSystemDataSource  implements JRDataSource {<br>File[] files = null;<br>int index = -1;<br>public JRFileSystemDataSource(String path) {<br>File dir = new File(path);<br>if (dir.exists() &amp;&amp; dir.isDirectory()) {<br>files = dir.listFiles();<br>}<br>}<br><br>@Override<br>public boolean next() throws JRException {<br>index++;<br>if (files != null &amp;&amp; index &lt; files.length) {<br>return true;<br>}<br>return false;<br>}<br><br>@Override<br>public Object getFieldValue(JRField jrf) throws JRException {<br>File f = files[index];<br>if (f == null) {<br>return null;<br>}<br>if (jrf.getName().equals("name")) {<br>return f.getName();<br>} else if (jrf.getName().equals("IS_DIRECTORY")) {<br>return new Boolean(f.isDirectory());<br>} else if (jrf.getName().equals("totalSpace")) {<br>return new Long(f.length());<br>}<br>// Field not found...<br>return null;<br>}<br><br>/**<br>* This method is responsible for setting the field names in the provider.(Required for the provider)<br>* @return <br>*/<br>public static String[] fieldNames() { <br>String[]  fieldNames = {"name", "IS_DIRECTORY", "totalSpace"}; <br>return fieldNames; <br>} <br>}<br><i>CODE SCRIPTLET #1</i></blockquote></div>The <b><i> fieldNames()</i></b>  method is not required for custom JRDataSource , but is required for JRDataSource Provider.<br><br><b>Now for the custom JRDatasource</b><br>1. The JRDataSource as shown above.(Remove the last method not required.)<br>2. The Factory Class for the custom JRDataSource looks like.<br><br><blockquote style="background-color:#E6E6FA;width:400px;">/** <br>*<br>* @author Ankur Gupta<br>*/<br>public class FactoryClassDataSource {<br><br>/**<br>* Factory Class responsible for setting the JRdatasource.<br>* @return <br>*/<br>public static JRDataSource generateDS(){<br>return new JRFileSystemDataSource("Path of the desired folder");<br>}<br>} <br><i>CODE SCRIPTLET #2</i></blockquote></div><br>This is it, now you can compile these two classes , and place the jar file in the class path.<br><br><b>Now for the  JRDatasource Provider.</b><br>1. The JRDataSource as shown as above in the code scriptet #1.<br>2. Next is the JRDataSourceProvider class shown as below.<br><br><br><blockquote style="background-color:#E6E6FA;width:400px;">/** <br>* JRDatasource Provider<br>* @author Ankur Gupta<br>*/<br>public class JRFileSystemDataSourceProvider implements JRDataSourceProvider{<br><br>@Override<br>public boolean supportsGetFieldsOperation() {<br>return false;<br>}<br><br>@Override<br>public JRField[] getFields(JasperReport jr) throws JRException, UnsupportedOperationException {<br><br>ArrayList fields = new ArrayList();<br>String [] fieldNames = JRFileSystemDataSource.fieldNames();<br>for (String s : fieldNames) {<br>JRDesignField field = new JRDesignField();<br>field.setName(s);<br>field.setValueClassName("java.lang.String");<br>fields.add(field);<br>}<br>return (JRField[]) fields.toArray(new JRField[fields.size()]);<br>}<br><br>@Override<br>public JRDataSource create(JasperReport jr) throws JRException {<br>return new JRFileSystemDataSource("Enter the path of folder");<br>}<br><br>@Override<br>public void dispose(JRDataSource jrds) throws JRException {<br>}<br><br>}<br><i>CODE SCRIPTLET #3</i></blockquote><br>Now, you can compile the classes and get the jar and place it in the classpath of iReport.<br><br>This was the portion you need to complete in creating the JAR file, now we need to set the datasource in thr iReport .<br><b>For setting the datasource as custom JRDataSource</b>, you need to enter the qualified path of the factory class. In iReport it looks like :<br><br>  <br><table align="center" cellpadding="0" cellspacing="0" style="margin-left:auto;margin-right:auto;text-align:center;"><tbody><tr><td style="text-align:center;"><a href="http://1.bp.blogspot.com/-_CrpW-qhyUQ/UrQ_j22EymI/AAAAAAAAAZI/GysfhI7vsg8/s1600/Untitled.png" style="margin-left:auto;margin-right:auto;" rel="external nofollow"><span>http://1.bp.blogspot.com/-_CrpW-qhyUQ/UrQ_j22EymI/AAAAAAAAAZI/GysfhI7vsg8/s400/Untitled.png</span></a></td></tr><tr><td style="text-align:center;">Custom JRDataSource<br><br></td></tr></tbody></table>Now you need to create the fields in the iReport by doing a right click on the field node and remember that the name of the field should be same as in the datasource . In the sample we need to create 3 fields as  name, IS_DIRECRTORY,totalSpace. <div>And then place these fields in the detail section of the report and then preview the report and then you could see the contents of the folder(In the sample the folder path is set to C drive.)</div><div><br></div><div><b>For setting the datasource as JRDataSourceProvider</b>, you need to set datasource by selecting to create a new datasource of type JRDataSourceProvider. In the sample it looks like</div><table align="center" cellpadding="0" cellspacing="0" style="margin-left:auto;margin-right:auto;text-align:center;"><tbody><tr><td style="text-align:center;"><a href="http://3.bp.blogspot.com/-DIR1zeXXhK0/UrRBRAbCt-I/AAAAAAAAAZU/kiMn3vpRjkA/s1600/Untitled.png" style="margin-left:auto;margin-right:auto;" rel="external nofollow"><span>http://3.bp.blogspot.com/-DIR1zeXXhK0/UrRBRAbCt-I/AAAAAAAAAZU/kiMn3vpRjkA/s400/Untitled.png</span></a></td></tr><tr><td style="text-align:center;">JRDataSourceProvider</td></tr></tbody></table><br>Now the difference in the custom JRDataSource and JRDataSource Provider is that in this function you will not be worried for creating the field  you could directly fetch it by going to the <b>Report query, </b>navigate to <b>DataSource Provider tab</b> and click on<b> Get Fields from dataSource , </b>it will display all the fields in case of this sample it look like :<br><div><br></div><div style="clear:both;text-align:center;"><a href="http://2.bp.blogspot.com/-sx-NIOT8tYI/UrRCu8K7XJI/AAAAAAAAAZg/ZqQzkb34ms4/s1600/Untitled.png" style="margin-left:1em;margin-right:1em;" rel="external nofollow"><span>http://2.bp.blogspot.com/-sx-NIOT8tYI/UrRCu8K7XJI/AAAAAAAAAZg/ZqQzkb34ms4/s400/Untitled.png</span></a></div><div><br><br><div>You then use the fields in the report and you can obtain similar structure of folder.</div></div><div><br></div><div><br></div><div>Here is the sample ZIP file </div><div><br></div><div>                                                              <a href="https://drive.google.com/file/d/0B4yFyF_EORB_NnFkZHNfNVhlY0E/edit?usp=sharing" rel="external nofollow">==ZIP FILE==</a></div><div>This ZIP  file will contain</div><div>1, TestRun PDF</div><div>2. JRXMLs for both the custonm JRDataSource as well  as JRDataSource Provider</div><div>3, JAR file which is needed to be placed in the classpath of iReport.</div><div><br></div><div>You could follow the video and sample and learn how to set the datasource with JRDataSource easily.</div><div><br></div><div>Please put you questions or demands for clarification in the comments section below.</div><div><br></div><div>Happy Coding.,,,!!!</div><div></div>]]></description><guid isPermaLink="false">162</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to set JavaBean set as Datasource in iReports, along with a working sample.</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-set-javabean-set-datasource-ireports-along-working-sample/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">Java beans are practically,  classes that encapsulate many objects into a single object (the bean). This is pretty simple to create and could easily hold lots of data in them. They are serializable, have a 0-argument constructor, and allow access to properties using getter and setter methods.<br><div><br></div><div>In a nutshell, java bean is easy to use methodology to obtain data. Now the task in hand is that how to use this bean in our reports . For setting the bean in reports there are few prerequisites, </div><div><br></div><div><ol style="text-align:left;"><li>There should be a Bean class</li><li>There should be a factory class which returns the collection/array of the beans</li></ol><div>iReport provides two options, either it could read from collection of beans or array of beans. First of all we need a bean, so below is how the bean looks like.</div></div><blockquote style="background-color:#E6E6FA;width:400px;">/**<br>* Bean<br>* <br>* @author Ankur Gupta<br>*/<br>public class PersonBean {<br>private String name = ""; <br>private int age = 0;<br>public PersonBean(String name, int age) {<br>this.name = name;<br>this.age = age;<br>}<br>public int getAge() {<br>return age;<br>}<br>public String getName() {<br>return name;<br>}<br>}</blockquote></div><div><br>Now you need to create a factory class which contains the function which returns the bean.There are two ways to do that :<br>1. Collection of bean<br><br></div><div><blockquote style="background-color:#E6E6FA;width:400px;">/** <br>* Responsible for filling values in the Bean and return it as collection of bean.<br>*<br>* @author Ankur Gupta<br>*/<br>public class TestFactory {<br><br>public static java.util.Collection generateCollection() {<br>// Creates the collection<br>java.util.Vector collection = new java.util.Vector();<br><br>// Adds the values in the bean and adds it into the collection<br>collection.add(new PersonBean("Ted", 20));<br>collection.add(new PersonBean("Jack", 34));<br>collection.add(new PersonBean("Bob", 56));<br>collection.add(new PersonBean("Alice", 12));<br>collection.add(new PersonBean("Robin", 22));<br>collection.add(new PersonBean("Peter", 28));<br><br>// returns the collection of beans.<br>return collection;<br>}<br>}</blockquote></div>2. Array of Beans<br><br><blockquote style="background-color:#E6E6FA;width:400px;">/** <br>* Responsible for filling values in the Bean and return it as collection of bean.<br>*<br>* @author Ankur Gupta<br>*/<br>public class TestFactory {<br><br>// Creates the Arraylist<br>PersonBean[] list = new PersonBean[6];<br><br>// Adds the values in the bean and adds it into the Array<br>list[0]= (new PersonBean("Ted", 20));<br>list[1]= (new PersonBean("Jack", 34));<br>list[2]= (new PersonBean("Bob", 56));<br>list[3]= (new PersonBean("Alice", 12));<br>list[4]= (new PersonBean("Robin", 22));<br>list[5]= (new PersonBean("Peter", 28));<br><br>// returns the Array of beans.<br>return list;<br>}<br>}</blockquote><br>Now, we need to compile these files  and put the generated jar file in the classpath of the iReport.<br><br>Next we need to set the datasource, by adding datasource Java Bean set as datasource and fill in the Factory class as well as the function which generates the bean as array or collection, whichever suits our purpose.<br><br>In this case:<br><b>Factory class </b> :  javabeanset.TestFactory<br><b>Generating function</b>: generateBeanArray/generateCollection (based upon collection or array)<br>Below are some screen shots.<br><br><div style="clear:both;text-align:center;"></div><table align="center" cellpadding="0" cellspacing="0" style="margin-left:auto;margin-right:auto;text-align:center;"><tbody><tr><td style="text-align:center;"><a href="http://1.bp.blogspot.com/-kRCYrv4FigE/UrQk3qR8K9I/AAAAAAAAAYw/bH2zTQQcZHk/s1600/Untitled.png" style="margin-left:auto;margin-right:auto;" rel="external nofollow"><span>http://1.bp.blogspot.com/-kRCYrv4FigE/UrQk3qR8K9I/AAAAAAAAAYw/bH2zTQQcZHk/s400/Untitled.png</span></a></td></tr><tr><td style="text-align:center;">Array of JavaBeans</td></tr></tbody></table><br><br><br><table align="center" cellpadding="0" cellspacing="0" style="margin-left:auto;margin-right:auto;text-align:center;"><tbody><tr><td style="text-align:center;"><a href="http://4.bp.blogspot.com/-wtHdWNEB30o/UrQlOM5YsNI/AAAAAAAAAY4/yXihZsrIWmU/s1600/Untitled.png" style="margin-left:auto;margin-right:auto;" rel="external nofollow"><span>http://4.bp.blogspot.com/-wtHdWNEB30o/UrQlOM5YsNI/AAAAAAAAAY4/yXihZsrIWmU/s400/Untitled.png</span></a></td></tr><tr><td style="text-align:center;">Collection of JavaBeans</td></tr></tbody></table><br>You can follow the video link for setting javabeans as datasource.  Here is the Youtube video made by me which gives a complete walkthrough to set the datasource as javabean with the help of a sample report also.<br><br>                                                                   
<div class="ipsEmbeddedVideo" contenteditable="false"><div><iframe width="200" height="113" src="https://www.youtube-nocookie.com/embed/ZMHYwlDcrN0?feature=oembed" frameborder="0" allowfullscreen="" title="Setting Java bean set as datasource in iReport - Follow link in description for sample" loading="lazy"></iframe></div></div><br><br><br><br>I have made a sample in the video itself here is zip file which contains:<br>1, Jar File (You need to place this in your classpath)<br>2. JRXML File<br>3. Set datasource as shown in the video and insert the values provided in the above screenshots.<br>4. Test Run PDF(PDF output of the Sample report)<br>                                                           <a href="https://drive.google.com/file/d/0B4yFyF_EORB_U3R0Uy12SE5SNWM/edit?usp=sharing" rel="external nofollow"> == ZIP Sample File ==</a><br>Follow all the steps in order to get the sample working.<br><br><br>Hope this clears your doubt for this topic. Still if you face any issues or problems then you can add a comment below .<br><br>Happy Coding.!!<br><br>]]></description><guid isPermaLink="false">160</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to execute Jasper Report through Java?</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-execute-jasper-report-through-java/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">I found a way for that by<em><strong> parsing the xml</strong></em> and then extracting the tags with <b>parameter </b>and retrieving the<em><strong> attribute name and class</strong></em> keeping in mind the check attribute <em><strong> isForPrompting is blank or not present for the parameters</strong></em> , In this way I got the Hashmap of all the parameters with their types and I put that in the parameterMap and hence fulfilling the parameters in the jrxml dynamically<br /><br /><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">The jars need to be included are-</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">1.commons-beanutils-x.x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">2.commons-collections-x.x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">3.commons-digester-x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">4.commons-logging-x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">5.groovy-all-x.x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">6.iText-x.x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">7.jasperreports-x.x.x.jar</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">8.poi-x.x.jar(for excel export)</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">9.jfreechart-x.x.x.jar<br /><br /><br />Happy Coding!!</div></div>]]></description><guid isPermaLink="false">158</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to make global header and footer in Jasper Reports?</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-make-global-header-and-footer-jasper-reports/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Hi,</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Suppose there are reports <span style="background-color:#FFFF00;margin:0px;padding:0px;">ABX,BNC and KLM</span>  which have a same header and footer Then what you can do is create a master Report suppose <span style="background-color:#FFF0F5;margin:0px;padding:0px;">mainReport</span>, in there you add 3 subreports in the <span style="background-color:#FFF0F5;margin:0px;padding:0px;">details section </span>and then  and give the path of the the three reports ABX,BNC and KLM.  </div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">You will have to specify the input control in the mainReport which user will have to enter suppose<span style="background-color:#FFFF00;margin:0px;padding:0px;"> REPORT_SELECTION.</span> Now you will have to decide the disctinct codes for each of the subreports . Suppose in this case I assign codes as :</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="background-color:#FAEBD7;margin:0px;padding:0px;">ABX-1</span><br /><span style="background-color:#FAEBD7;margin:0px;padding:0px;">BNC-2</span><br /><span style="background-color:#FAEBD7;margin:0px;padding:0px;">KLM-3 </span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">It  would accept the 1,2,3 from the user as input from the user in the parameter $P{REPORT_SELECTION} on the basis of this very choice of user it will trigger the presence or absence of the subreport.(<span style="color:#0000FF;margin:0px;padding:0px;">Here 1,2,3 are just the cases could be anything like A,B,C or name itself like "ABX","BNC","KLM"</span> )</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Now to trigger the appearance of the subreport on the basis of this parameter $P{REPORT_SELECTION} ,which is entered by user we need to write the print when expression. The printwhen expression(which you would find in the property of the subreport element) you need to specify it as  : <span style="background-color:#DDA0DD;margin:0px;padding:0px;">$P{REPORT_SELECTION}  ==1 </span>(This will be for the report <span style="background-color:#FFFF00;margin:0px;padding:0px;">ABX</span> ). So in this way the expression will vary. and you will get the desired subreport.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Please keep in mind that in the subreports header and footer is removed .</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Here the input control REPORT_SELECTION is included on the mainReport so would be global too, and even you could accept the values of other parameters required by the reports and then pass it on to the subreports.So the parameters or input controls would be turned global too.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><div style="line-height:13.5pt;margin-bottom:0.0001pt;margin:0in;"><span style="font-family:Arial, sans-serif;font-size:10.5pt;">Hope thatabove explanation helps .</span><p></p></div><div style="line-height:13.5pt;margin-bottom:0.0001pt;margin:0in;"><br /></div><br /><div style="line-height:13.5pt;margin-bottom:0.0001pt;margin:0in;"><span style="font-family:Arial, sans-serif;font-size:10.5pt;">HappyCoding!!</span><p></p></div></div></div>]]></description><guid isPermaLink="false">157</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to decorate reports in Jasper Reports , and how can we produce certificates with Jasper reports?</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-decorate-reports-jasper-reports-and-how-can-we-produce-certificates-jasper-reports/</link><description><![CDATA[<div dir="ltr" style="text-align:left;"><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
What you need to do is add a property to the fields you are wanting referenced. To add the class name you need to add net.sf.jasperreports.export.html.class and to include an id you need to addnet.sf.jasperreports.export.html.id as a property. As an example, below is a Text field that sets both:</div><br />
<div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin:0.5em;padding:0.5em;"><br />
<div style="font-family:monospace;margin:0px;padding:0px;"><br />
<pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;"><span style="color:#339933;margin:0px;padding:0px;">&lt;</span>textField<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
    <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>reportElement uuid<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"2399e4ef-633c-4d17-b964-3e093ece1936"</span> x<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"0"</span> y<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"22"</span> width<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"100"</span> height<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"20"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
        <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>property name<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"net.sf.jasperreports.export.html.class"</span> value<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"TEST"</span><span style="color:#339933;margin:0px;padding:0px;">/&gt;</span><br />
        <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>property name<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"net.sf.jasperreports.export.html.id"</span> value<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"ID"</span><span style="color:#339933;margin:0px;padding:0px;">/&gt;</span><br />
    <span style="color:#339933;margin:0px;padding:0px;">&lt;/</span>reportElement<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
    <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>textElement markup<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"html"</span><span style="color:#339933;margin:0px;padding:0px;">/&gt;</span><br />
    <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>textFieldExpression<span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;!</span><span style="color:#009900;margin:0px;padding:0px;">[</span>CDATA<span style="color:#009900;margin:0px;padding:0px;">[</span><span style="color:#009900;margin:0px;padding:0px;">(</span>$F<span style="color:#009900;margin:0px;padding:0px;">{</span>field1<span style="color:#009900;margin:0px;padding:0px;">}</span><span style="color:#009900;margin:0px;padding:0px;">]</span><span style="color:#009900;margin:0px;padding:0px;">]</span><span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;/</span>textFieldExpression<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;/</span>textField<span style="color:#339933;margin:0px;padding:0px;">&gt;</span></pre><br />
</div><br />
</div><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
In iReport you add these by selecting the field, and then in the properties window clicking the ellipses button next to Properties expressions. <span>http://i.stack.imgur.com/mIRwA.png</span></div><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
To include the link to the css file in the exported report, you need to set the value for theJRHtmlExporterParameter.HTML_HEADER parameter before exporting. Note the parameter is not the header in the sense of HTML (the contents of the head tag), but the header of the exported HTML report. Meaning it is what is first placed in the exported report to begin with, before including the report. The default that Jasper Reports uses is:</div><br />
<div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin:0.5em;padding:0.5em;"><br />
<div style="font-family:monospace;margin:0px;padding:0px;"><br />
<pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;"><span style="color:#339933;margin:0px;padding:0px;">&lt;</span>html<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;</span>head<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
  <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>title<span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;/</span>title<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
  <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>meta http<span style="color:#339933;margin:0px;padding:0px;">-</span>equiv<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"Content-Type"</span> content<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"text/html; charset=UTF-8"</span><span style="color:#339933;margin:0px;padding:0px;">/&gt;</span><br />
  <span style="color:#339933;margin:0px;padding:0px;">&lt;</span>style type<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"text/css"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
    a <span style="color:#009900;margin:0px;padding:0px;">{</span>text<span style="color:#339933;margin:0px;padding:0px;">-</span>decoration<span style="color:#339933;margin:0px;padding:0px;">:</span> none<span style="color:#009900;margin:0px;padding:0px;">}</span><br />
  <span style="color:#339933;margin:0px;padding:0px;">&lt;/</span>style<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;/</span>head<span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;</span>body text<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"#000000"</span> link<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"#000000"</span> alink<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"#000000"</span> vlink<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"#000000"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;</span>table width<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"100%"</span> cellpadding<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"0"</span> cellspacing<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"0"</span> border<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"0"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;</span><br />
<span style="color:#339933;margin:0px;padding:0px;">&lt;</span>tr<span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;</span>td width<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"50%"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;&amp;</span>nbsp<span style="color:#339933;margin:0px;padding:0px;">;&lt;/</span>td<span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;</span>td align<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"center"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;</span></pre><br />
</div><br />
</div><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
So you will need to modify this to include the link to your stylesheet by adding:</div><br />
<div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin:0.5em;padding:0.5em;"><br />
<div style="font-family:monospace;margin:0px;padding:0px;"><br />
<pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;"><span style="color:#339933;margin:0px;padding:0px;">&lt;</span>link rel<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"stylesheet"</span> type<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"text/css"</span> href<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"&lt;cssfile you want to point to&gt;"</span> <span style="color:#339933;margin:0px;padding:0px;">/&gt;</span></pre><br />
</div><br />
</div><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
to that in the appropriate place, which I think is inside the head tag, but if not move to appropriate area. So the java code would end looking something like:</div><br />
<div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin:0.5em;padding:0.5em;"><br />
<div style="font-family:monospace;margin:0px;padding:0px;"><br />
<pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;"><span style="color:#339933;margin:0px;padding:0px;">&lt;</span>span style<span style="color:#339933;margin:0px;padding:0px;">=</span><span style="color:#0000FF;margin:0px;padding:0px;">"font-size:11px;"</span><span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;</span>strong<span style="color:#339933;margin:0px;padding:0px;">&gt;</span>JRHtmlExporter exporter <span style="color:#339933;margin:0px;padding:0px;">=</span> <span style="color:#000000;font-weight:bold;margin:0px;padding:0px;">new</span> JRHtmlExporter<span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">;</span><br />
exporter.<span style="color:#006633;margin:0px;padding:0px;">setParameter</span><span style="color:#009900;margin:0px;padding:0px;">(</span>JRExporterParameter.<span style="color:#006633;margin:0px;padding:0px;">JASPER_PRINT</span>, jasperPrint<span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">;</span><br />
exporter.<span style="color:#006633;margin:0px;padding:0px;">setParameter</span><span style="color:#009900;margin:0px;padding:0px;">(</span>JRHtmlExporterParameter.<span style="color:#006633;margin:0px;padding:0px;">HTML_HEADER</span>, <br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;html&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;head&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"  &lt;title&gt;&lt;/title&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"  &lt;meta http-equiv="</span>Content<span style="color:#339933;margin:0px;padding:0px;">-</span>Type<span style="color:#0000FF;margin:0px;padding:0px;">" content="</span>text<span style="color:#339933;margin:0px;padding:0px;">/</span>html<span style="color:#339933;margin:0px;padding:0px;">;</span> charset<span style="color:#339933;margin:0px;padding:0px;">=</span>UTF<span style="color:#339933;margin:0px;padding:0px;">-</span>8<span style="color:#0000FF;margin:0px;padding:0px;">"/&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"  &lt;link rel=<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span>stylesheet<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span> type=<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span>text/css<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span> href=<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span>css/jasper.css<span style="color:#000099;font-weight:bold;margin:0px;padding:0px;">\"</span> /&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"  &lt;style type="</span>text<span style="color:#339933;margin:0px;padding:0px;">/</span>css<span style="color:#0000FF;margin:0px;padding:0px;">"&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"    a {text-decoration: none}"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"  &lt;/style&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;/head&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;body text="</span>#000000<span style="color:#0000FF;margin:0px;padding:0px;">" link="</span>#000000<span style="color:#0000FF;margin:0px;padding:0px;">" alink="</span>#000000<span style="color:#0000FF;margin:0px;padding:0px;">" vlink="</span>#000000<span style="color:#0000FF;margin:0px;padding:0px;">"&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;table width="</span>100<span style="color:#339933;margin:0px;padding:0px;">%</span><span style="color:#0000FF;margin:0px;padding:0px;">" cellpadding="</span>0<span style="color:#0000FF;margin:0px;padding:0px;">" cellspacing="</span>0<span style="color:#0000FF;margin:0px;padding:0px;">" border="</span>0<span style="color:#0000FF;margin:0px;padding:0px;">"&gt;"</span><span style="color:#339933;margin:0px;padding:0px;">+</span><br />
    <span style="color:#0000FF;margin:0px;padding:0px;">"&lt;tr&gt;&lt;td width="</span>50<span style="color:#339933;margin:0px;padding:0px;">%</span><span style="color:#0000FF;margin:0px;padding:0px;">"&gt; &lt;/td&gt;&lt;td align="</span>center<span style="color:#0000FF;margin:0px;padding:0px;">"&gt;"</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">;</span><br />
exporter.<span style="color:#006633;margin:0px;padding:0px;">exportReport</span><span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">;&lt;/</span>strong<span style="color:#339933;margin:0px;padding:0px;">&gt;&lt;/</span>span<span style="color:#339933;margin:0px;padding:0px;">&gt;</span></pre><br />
</div><br />
</div><br />
<div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br />
Hope that it helps</div><br />
</div><br />
]]></description><guid isPermaLink="false">156</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to format number when running report from Java code in iReport</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-format-number-when-running-report-java-code-ireport/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">There is always ambiguity that how could you format the data conditionally or at runtime of the report based upon the data in the iReport.<br /><br />iReport does provides a robust methodology to format the values of the textfield but sometime you require data to be formatted conditionally or needs to be formatted not at the design time but needs to be modified dynamically, that is, based upon the data coming from the datasource or upon the user choice. So this particular article is dedicated to cater this very problem.<br /><br /><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">The formatting done in the iReport is report specific it like extra utility , of providing the pattern provided by the iReport. When you run that in java code the formatting is removed. So what you can do for the java code is that you could use:</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="background-color:#FFA07A;margin:0px;padding:0px;"> new java.text.DecimalFormat("pattern").format(put the field here)</span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">So to provide similarity in the report and in the Java code what can be done is that you could replace the expression of the text field with the same expression and the discrepancy could be easily taken care off.In that case the expression would look something like this</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="background-color:#FFFF00;margin:0px;padding:0px;"> new java.text.DecimalFormat("¤ #,##0").format($F{VALUE})   </span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Now here the in the field expression easily , any field or parameter could be put and same would work fine for java code too,</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Here any pattern can be put, and formatting could be applied to any described field.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Cheers Happy Coding....!!</div></div>]]></description><guid isPermaLink="false">155</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to add user defined function in iReport </title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-add-user-defined-function-ireport/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">In iReport it is very important to have a knowledge of integrating the Java code with the Jasper Report as the things do easier and provide lot of versatility to the report. Usage of Java Code in iReport is achieved by usage of scriptlets.<br /><br />Scriptlets acts as bridge to get the Java Code in the iReport, scriptlet is a Java class which extends the JRDefaultScriptlet, and in this class we could write our user defined functions which later could be easily accessed in the report.<br /><br /><br />There are few simple steps which could be followed in order to run the User Defined Functions.<br /><br /><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">1. <b>Tools</b>(in the iReport Menu bar ) -----&gt;  <b>Options </b>-----&gt; Click on <b>Claspath </b>Tab ------&gt; <b>ADD Jar</b> -----&gt; choose the Jar file ( This JAR is made on building the project containing the scriptlet )</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">2. Then in the iReport there is a node called <b>Scriptlet </b>in the<b> Report Inspector</b> ( By Default on left ).</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">3. Go to the properties of the scriptlet , there is a property called '<b>Scriptlet Class</b>'</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">4. Key in the the location of the scriptlet class where the user defined function is present  for instance:</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><i>com.jasper.scriptlet.TestScriptlet -- In this scenario TestScriptlet is my class where the user defined function is written.</i></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">(<b>Remember the the class containing the user defined function needs to be extended by the JRDefaultScriptlet )</b></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">5. Now you are set to use it in the report, to use in the iReport you need to use the reference of a parameter called <b>$P{REPORT_SCRIPTLET} ,</b> this is a predefined parameter which could come handy.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"> 6. In order to use the user defined in the iReport, in the the expression would be given as </div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"> <b>$P{REPORT_SCRIPTLET} .userDefinedFun() -  </b>This is a user defined function which returns values from the scriptlet.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><b>$P{REPORT_SCRIPTLET} .userDefinedFun($F{field})  - </b>This is also a user defined function which returns values from scriptlet, but has an input parameter from the field in the report. So this gives fluidity of the Java from Jasper to Java code.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Here is a running sample-<br /><br />Prerequesites- <br />1. <a href="https://drive.google.com/file/d/0B4yFyF_EORB_b1E5NnlTZXVMc0k/edit?usp=sharing" rel="external nofollow">JRXML File</a><br />2. <a href="https://drive.google.com/file/d/0B4yFyF_EORB_LWJTYXI5VDBSYTQ/edit?usp=sharing" rel="external nofollow">Jar File</a><br />3. <a href="https://drive.google.com/file/d/0B4yFyF_EORB_TS1nWjlFc0RXUGM/edit?usp=sharing" rel="external nofollow">PDF Export</a>  <br /><br />Steps to set up this Sample Report.<br /><div style="color:#000000;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;margin:1em 0px;padding:0px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">1. <b>Tools</b>(in the iReport Menu bar )-----&gt; <b>Options </b>----- &gt; Click on <b>Claspath </b>Tab ------&gt; ADD <b>Jar </b>-----&gt; choose the Jar file</div><div style="color:#000000;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;margin:1em 0px;padding:0px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">2.  Then navigate to <b>Scriptlet node </b>in the Report inspector, and then modify the property<b> Scriptlet Class</b> to <b>'pkg1.ConvertToWord'</b></div><div style="color:#000000;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;margin:1em 0px;padding:0px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">3. Then you must choose <b>Sample Database</b> in the datasource</div><div style="color:#000000;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;margin:1em 0px;padding:0px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">4. Then next you need to activate the the sample database from <b>Help</b>(in the iReport Menu bar)----&gt;<b>Samples</b>----&gt;<b>Run Sample Database</b></div><div style="color:#000000;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;margin:1em 0px;padding:0px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">5. Then Run the  Report</div>There is a PDF export also which would show exactly how the report looks.<br /><br />Please put in you queries/suggestions, I will be more than happy to know. </div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Cheers .. Happy Coding!!</div></div>]]></description><guid isPermaLink="false">154</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>How to write conditional query in iReport using parameters</title><link>https://community.jaspersoft.com/blog/agiletech-ankur-gupta/how-write-conditional-query-ireport-using-parameters/</link><description><![CDATA[<div dir="ltr" style="text-align:left;">Inside iReport creating static query that is, writing a simple static query in the the Query executor and set it up running is quite simple and too monotonous.<br /><br />The real challenge arrives in actually changing the query of the report dynamically based upon some condition, this could be achieved with a simple implementation of parameters.<br /><br />Following are the steps to use the conditional SQL Statements.<br /><br />1. Create a parameter if you want user triggered change of the SQL Query , if not user triggered then it must be based upon the field, so that can be used too.<br /><br />2. Create a different parameter which will be responsible for triggering the changed query based upon the condition.<br /><br />3. Now identify the condition which is responsible for changing the query,<br /><br />4. The parameter which contains the conditional SQL switching should have the property "Used as prompt" turned off and the condition should be placed in the default value.<br /><br />5. Then after setting this, move onto set the Report Query Expression. Now see the dynamism of the query could be provided to the whole query or a portion of query so accordingly place the expression .The parameter containing the conditional expression should be used as the expression and it should be denoted as <b>$P!{name of the param containing expression}</b><br /><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Here is a little illustration</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Suppose there is a parameter called $P{TestParamSQL}, the prompt should be turned off as we are setting the value at runtime checking the value of the <em>$P{TEST_PARAM}. </em></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Set the default value of the parameter as:</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">For a single condition </div><div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:1.3;margin:0.5em;padding:0.5em;"><div style="font-family:monospace;margin:0px;padding:0px;"><pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;">$P<span style="color:#009900;margin:0px;padding:0px;">{</span>TEST_PARAM<span style="color:#009900;margin:0px;padding:0px;">}</span>.<span style="color:#006633;margin:0px;padding:0px;">equals</span><span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#0000FF;margin:0px;padding:0px;">"test"</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">?</span> <span style="color:#0000FF;margin:0px;padding:0px;">" select SQL query"</span><span style="color:#339933;margin:0px;padding:0px;">:</span> <span style="color:#0000FF;margin:0px;padding:0px;">" else SQL select query"</span></pre></div></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="font-size:12px;margin:0px;padding:0px;">For a multiple condition </span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="background-color:#f8f8f8;border:1px solid rgb(204,204,204);color:#222222;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:1.3;margin:0.5em;padding:0.5em;"><div style="font-family:monospace;margin:0px;padding:0px;"><pre style="font-size:12px;line-height:1.3;padding:0px;white-space:pre-wrap;">$P<span style="color:#009900;margin:0px;padding:0px;">{</span>TEST_PARAM<span style="color:#009900;margin:0px;padding:0px;">}</span>.<span style="color:#006633;margin:0px;padding:0px;">equals</span><span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#0000FF;margin:0px;padding:0px;">"test"</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">?</span> <span style="color:#0000FF;margin:0px;padding:0px;">" select SQL query"</span><span style="color:#339933;margin:0px;padding:0px;">:</span> $P<span style="color:#009900;margin:0px;padding:0px;">{</span>TEST_PARAM<span style="color:#009900;margin:0px;padding:0px;">}</span>.<span style="color:#006633;margin:0px;padding:0px;">equals</span><span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#0000FF;margin:0px;padding:0px;">"test1"</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">?</span> <span style="color:#0000FF;margin:0px;padding:0px;">" SQL select query"</span><span style="color:#339933;margin:0px;padding:0px;">:</span> $P<span style="color:#009900;margin:0px;padding:0px;">{</span>TEST_PARAM<span style="color:#009900;margin:0px;padding:0px;">}</span>.<span style="color:#006633;margin:0px;padding:0px;">equals</span><span style="color:#009900;margin:0px;padding:0px;">(</span><span style="color:#0000FF;margin:0px;padding:0px;">"test2"</span><span style="color:#009900;margin:0px;padding:0px;">)</span><span style="color:#339933;margin:0px;padding:0px;">?</span><span style="color:#0000FF;margin:0px;padding:0px;">" SQL Query"</span><span style="color:#339933;margin:0px;padding:0px;">:</span> <span style="color:#0000FF;margin:0px;padding:0px;">"else SQL Query"</span></pre></div></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><em>Now in the iReport Query executor you should give the following expression</em><strong><span style="font-size:12px;margin:0px;padding:0px;">$P!{TestParamSQL}</span></strong> </div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><br /></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="font-size:x-small;"><b>Do take care that the dependent parameter $P{TEST_PARAM}. should be set before the <span style="margin:0px;padding:0px;">$P{TestParamSQL} else would throw a null pointer exception.</span></b></span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="margin:0px;padding:0px;"><span style="font-size:x-small;"><b>Another thing which should be kept in mind is that the query given in the quotes in the expression should be syntactically correct, that is the SQL in as the string should be correct.</b></span></span></div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="margin:0px;padding:0px;"><span style="font-size:x-small;"><b><br /></b></span></span></div><div style="background-color:#fefdfa;color:#333333;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Here is a running sample-<br /><br />Prerequesites-<br />1. <a href="https://drive.google.com/file/d/0B4yFyF_EORB_eW1kOEFxUTRJSEE/edit?usp=sharing" style="color:#7d181e;text-decoration:none;" rel="external nofollow">JRXML File</a><br />2. <a href="https://drive.google.com/file/d/0B4yFyF_EORB_eW1kOEFxUTRJSEE/edit?usp=sharing" style="color:#7d181e;text-decoration:none;" rel="external nofollow">PDF Export</a><br /><br />Steps to set up this Sample Report.<br /><div style="color:#000000;margin:1em 0px;padding:0px;">1. Then you must choose <b>Sample Database</b> in the datasource</div><div style="color:#000000;margin:1em 0px;padding:0px;">4. Then next you need to activate the the sample database from <b>Help</b>(in the iReport Menu bar)---&gt; <b>Samples</b>----&gt;<b>Run Sample Database</b></div><div style="color:#000000;margin:1em 0px;padding:0px;">5. Then Run the  Report</div><div style="color:#000000;margin:1em 0px;padding:0px;"><br /></div>There is a PDF export also which would show exactly how the report looks(The input value is employeeId= 2).<br /><br />Please put in you queries/suggestions, I will be more than happy to know.</div><div style="font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;"><span style="margin:0px;padding:0px;"></span></div><div style="background-color:#fefdfa;color:#333333;font-family:Arial, Helvetica, 'Nimbus Sans L', FreeSans, sans-serif;font-size:14px;line-height:18px;margin-bottom:1em;margin-top:1em;padding:0px;">Cheers .. Happy Coding!!</div></div>]]></description><guid isPermaLink="false">153</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item></channel></rss>
