Page
...
Contents
...
Implications
...
Page Contents
...
Objective
This page contains snippets and blocks of code that are useful for editing iReport XML templates.
Assumptions
- You have full admin access to ParadigmEMS
- You are a competent user of ParadigmEMS
You have already downloaded Jasper iReport v3.0, refer to Installing Jasper iReport
Warning | ||
---|---|---|
| ||
|
How to access iReport on Paradigm
- Log into your ParadigmEMS first.
- Click on Reports from side menu.
- Click on Report Edit, it shows a list of Reports/Letters.
- You can do a quick search for the report you need, type in the report name at the top left corner .
- Click on the pencil icon , scroll to the Report Properties section.
- Report Identifier = Report_id, please do not make any changes (refer to warning #1)
- Click on the Edit Labels (you should know where it is if you are a competent user) and scroll down to the bottom.
- Scroll to the bottom section - Report Edit: (report_id here)
- Click to download the Report that the name matches the Report identifier. Sometimes you will see more than one report, the rest are sub-reports (i.e. ReportHeader, Reportfooter).
- The report will download to your Downloads folder by default
Open a report in the Jasper iReport v3.0
...
Java Conditions
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
new Boolean($P{letterNumber}.equalsIgnoreCase("1st")||$P{letterNumber}.equalsIgnoreCase("2nd")) new Boolean ( ! $F{provider_code}.equals( "Morling" ) ) new Boolean( $V{amountDueTotal}.compareTo( new Double (0.00) ) > 0 ) new Boolean ( $V{PAGE_NUMBER}.toString() == "1" ) new Boolean ($F{chessn}!=null && !$P{unitEnrolmentEndDate}.equals("")) new Boolean ( $F{course_level}.equals("VET")) new Boolean ( $F{enrolment_status_id}.equals( "ENROLMENT_COMPLETED" ) ) |
Dates
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
new SimpleDateFormat("dd MMMM yyyy").format( new Date()) new java.util.Date(2017, 1, 1) "Teaching Period: " + new SimpleDateFormat("dd MMMM yyyy").format( $F{current_semester_name} ) new SimpleDateFormat("EEEEE, dd MMMMM yyyy").parse($P{todaysDate}) new SimpleDateFormat("dd/MM/yyyy").format($P{report_date}) "Admitted to the "+$F{course_name}+" on "+new SimpleDateFormat("MMMMM dd, yyyy").format($F{course_enrolment_start_date}) |
Casting
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
"You currently owe: $" + new DecimalFormat("###0.00").format($V{amountDueTotal}).toString() $V{PAGE_NUMBER}.toString() "Total credit points required: " + new DecimalFormat("0").format($F{credit_points_required}).toString() ( $V{gpa_total}==null ? new Double (0) : $V{gpa_total} ) |
Static field formatting
Inline casting of fields
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
"Accumulated grade point average: " + ( $V{gpa_total}==null ? "0.00" : new DecimalFormat("0.00").format($V{gpa_total}).toString() ) |
Uppercase
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Example: $V{studentFormalName}.toUpperCase() |
Text field formatting
Note | ||
---|---|---|
| ||
In the Font tab of the field's Properties window, set the "is styled text" to true, and in the Markup drop down, select the "HTML" option. "Is styled text" is now deprecated but still functions. |
Bold
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<style isBold=\"true\" pdfFontName=\"Helvetica-Bold\"> This becomes bold </style> |
Underline
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<style isUnderline=\"true\" >Underline me! </style> |
Italic
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<style isItalic=\"true\" pdfFontName=\"Helvetica-Oblique\"> I'm leaning to one side </style> |
Colour
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<style forecolor=\"#0000ff\"> Colour me surprised </style> |
Dot-points
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
+"•" |
Hyperlink
From https://stackoverflow.com/questions/11254009/create-an-external-url-hyperlink-with-jasperreports:
...
The hyperlinkTarget attribute behaves in the same way as the target attribute in HTML. Note that only textFields, images, and charts can be hyperlinked in this way.
Escaping
Escaping double quote
Code Block | ||||
---|---|---|---|---|
| ||||
"Thank you for your application for enrolment at Group Colleges Australia (\"GCA\") Pty Ltd trading as Universal Business School Sydney (UBSS)." |
Escaping special characters
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
"<style isBold=\"true\" pdfFontName=\"Helvetica-Bold\">" +$F{edu_other_unit_id}.trim() + "</style> (" + $F{unit_name}.replaceAll("&","&") + ")" |
MSWord Entities
Code Block | ||||
---|---|---|---|---|
| ||||
REGEXP_REPLACE(REGEXP_REPLACE(ce.content, '&[lr]dquo;', '"', 'g'), '–', '-', 'g') as content, |
Sample dynamic where clauses
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
( $P{eduProgramEnrolmentId}==null || $P{eduProgramEnrolmentId}.equals("") ? "" : " AND epe.edu_program_enrolment_id = '"+$P{eduProgramEnrolmentId}+"'" ) + ( $P{academicTermId}==null || $P{academicTermId}.equals("") ? "" : " AND tp.custom_time_period_id = '"+$P{academicTermId}+"'" ) + ( $P{courseId}==null || $P{courseId}.equals("") ? "" : " AND epe.edu_program_id = '"+$P{courseId}+"'" ) + ( $P{providerId}==null || $P{providerId}.equals("") ? "" : " AND epe.home_institution_party_id = '"+$P{providerId}+"'" ) + ( $P{studentNumber}==null || $P{studentNumber}.equals("") ? "" : " AND lsi.student_number = '"+$P{studentNumber}+"'" ) + ( $P{censusPeriodId}==null || $P{censusPeriodId}.equals("") ? "" : " AND esu.dest_census_date IN "+$P{censusPeriodId}) + /* ( $P{censusDateFrom}==null || $P{censusDateFrom}.equals("") ? "" : " AND esu.dest_census_date >= '"+$P{censusDateFrom}+"'" ) + ( $P{censusDateTo}==null || $P{censusDateTo}.equals("") ? "" : " AND esu.dest_census_date <= '"+$P{censusDateTo}+"'" ) + */ ( $P{unitEnrolmentStatus}==null || $P{unitEnrolmentStatus}.equals("") ? "" : " AND eue.enrolment_status_id IN "+$P{unitEnrolmentStatus} ) +((($P{eduProgramEnrolmentId}==null || $P{eduProgramEnrolmentId}.equals(""))&& ($P{academicTermId}==null || $P{academicTermId}.equals(""))&& ($P{courseId}==null || $P{courseId}.equals(""))&& ($P{providerId}==null || $P{providerId}.equals(""))&& ($P{studentNumber}==null || $P{studentNumber}.equals(""))&& ($P{censusDateFrom}==null || $P{censusDateFrom}.equals(""))&& ($P{censusDateTo}==null || $P{censusDateTo}.equals(""))&& ($P{censusPeriodId}==null || $P{censusPeriodId}.equals(""))&& ($P{unitEnrolmentStatus}==null || $P{unitEnrolmentStatus}.equals("")))?" AND epe.edu_program_enrolment_id='No Parameters'":"") |
Sample address blocks
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Residential Address: $F{first_name}+" "+$F{last_name}+"\n"+ ($F{residential_street_subaddress} != null && !$F{residential_street_subaddress}.equals("") ? $F{residential_street_subaddress}.replaceAll("\\\\'", "'") + "/" : "") + ($F{residential_street_number} != null && !$F{residential_street_number}.equals("") ? $F{residential_street_number}.replaceAll("\\\\'", "'") + " " : "") + ($F{residential_street_name} != null && !$F{residential_street_name}.equals("") ? $F{residential_street_name}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{residential_city} != null && !$F{residential_city}.equals("") ? $F{residential_city}.replaceAll("\\\\'", "'") + ", \t" : "") + ($F{residential_state_abbreviation}!= null && !$F{residential_state_abbreviation}.equals("") ? $F{residential_state_abbreviation}.replaceAll("\\\\'", "'") + " ": "") + ($F{residential_postal_code}!= null && !$F{residential_postal_code}.equals("") ? $F{residential_postal_code}.replaceAll("\\\\'", "'") + " ": "") + ($F{residential_country_geo_id} != null && !$F{residential_country_geo_id}.equals("") && !$F{residential_country_geo_id}.equals("AUSTRALIA") && !$F{residential_country_geo_id}.equals("AUS") ? "\n" + $F{residential_country_geo_id}.replaceAll("\\\\'", "'") : "") Billing Address: $F{first_name}+" "+$F{last_name}+"\n"+ ($F{billing_street_subaddress} != null && !$F{billing_street_subaddress}.equals("") ? $F{billing_street_subaddress}.replaceAll("\\\\'", "'") + "/" : "") + ($F{billing_street_number} != null && !$F{billing_street_number}.equals("") ? $F{billing_street_number}.replaceAll("\\\\'", "'") + " " : "") + ($F{billing_street_name} != null && !$F{billing_street_name}.equals("") ? $F{billing_street_name}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{billing_city} != null && !$F{billing_city}.equals("") ? $F{billing_city}.replaceAll("\\\\'", "'") + ", \t" : "") + ($F{billing_state_abbreviation}!= null && !$F{billing_state_abbreviation}.equals("") ? $F{billing_state_abbreviation}.replaceAll("\\\\'", "'") + " ": "") + ($F{billing_postal_code}!= null && !$F{billing_postal_code}.equals("") ? $F{billing_postal_code}.replaceAll("\\\\'", "'") + " ": "") + ($F{billing_country_geo_id} != null && !$F{billing_country_geo_id}.equals("") && !$F{billing_country_geo_id}.equals("AUSTRALIA") && !$F{billing_country_geo_id}.equals("AUS") ? "\n" + $F{billing_country_geo_id}.replaceAll("\\\\'", "'") : "") ($F{billing_property_name} != null ? $F{billing_property_name} + "\n" : "") + ($F{billing_street_subaddress} != null ? $F{billing_street_subaddress} + " " : "") + ($F{billing_postal_subaddress} != null ? $F{billing_postal_subaddress} + " " : "") + ($F{billing_street_subaddress} != null || $F{billing_street_subaddress} != null ? "\n" : "")+ ($F{billing_street_number} != null ? $F{billing_street_number} + " " : "") + ($F{billing_street_name} != null ? $F{billing_street_name} + "\n" : "") + ($F{billing_city} != null ? $F{billing_city} + " " : "") + ($F{billing_state_province_geo_id} != null ? $F{billing_state_province_geo_id} + " " : ($F{billing_state_abbreviation} != null ? $F{billing_state_abbreviation} + " " : " ")) + ($F{billing_postal_code} != null ? $F{billing_postal_code} + "\n" : "") + ($F{billing_country_name} != null ? $F{billing_country_name} + "\n" : "") ($F{billing_address1} != null ? $F{billing_address1}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{billing_address2} != null ? $F{billing_address2}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{billing_city} != null ? $F{billing_city}.replaceAll("\\\\'", "'") + '\t' : "") + " " + ($F{billing_state} != null ? $F{billing_state_abbrev}.replaceAll("\\\\'", "'") + " " : ($F{billing_state}!=null ? $F{billing_state}.replaceAll("\\\\'", "'") + " " : "")) + ($F{billing_postal_code} != null ? $F{billing_postal_code}.replaceAll("\\\\'", "'") : "") + ($F{billing_country} != null && !$F{billing_country}.equals("AUSTRALIA") ? "\n" + $F{billing_country}.replaceAll("\\\\'", "'") : "") ($F{postal_address1} != null ? $F{postal_address1}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{postal_address2} != null ? $F{postal_address2}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{postal_city} != null ? $F{postal_city}.replaceAll("\\\\'", "'") + '\t' : "") + " " + ($F{postal_state} != null ? $F{postal_state_abbrev}.replaceAll("\\\\'", "'") + " " : ($F{postal_state}!=null ? $F{postal_state}.replaceAll("\\\\'", "'") + " " : "")) + ($F{postal_state_abbrev} != null ? $F{postal_state_abbrev}.replaceAll("\\\\'", "'") : "") + ($F{postal_country} != null && !$F{postal_country}.equals("AUSTRALIA") ? "\n" + $F{postal_country}.replaceAll("\\\\'", "'") : "") ($F{residential_street_number} != null ? $F{residential_street_number}.replaceAll("\\\\'", "'") + ' ' : "") + ($F{residential_street_name} != null ? $F{residential_street_name}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{residential_street_subaddress} != null ? $F{residential_street_subaddress}.replaceAll("\\\\'", "'") + '\n' : "") + ($F{residential_city} != null ? $F{residential_city}.replaceAll("\\\\'", "'") + '\n' : "") + " " + ($F{residential_state} != null ? $F{residential_state}.replaceAll("\\\\'", "'") + " " : ($F{residential_state}!=null ? $F{residential_state}.replaceAll("\\\\'", "'") + " " : "")) + ($F{residential_postal_code} != null ? $F{residential_postal_code}.replaceAll("\\\\'", "'") + '\n' : "") + " " + ($F{residential_country_geo_id} != null && !$F{residential_country_geo_id}.equals("AUSTRALIA") ? "\n" + $F{residential_country_geo_id}.replaceAll("\\\\'", "'") : "") |
...