How to hide page header band on last page - variables

I think I am having a problem with evaluation time. In this example, you see the variable $P{REPORT_PARAMETERS_MAP}.get("LastPageNumber") reflecting the last page correctly; it updates correctly. But when I use it for the "printWhenExpression" of a detail band field (experiment) or for the page header band (my goal) it does not work.
I am using "page" evaluation time throughout which seems to work for the variable itself. But the printWhenExpressions are not working using this variable.
Here is my xml file :
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report3" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<queryString>
<![CDATA[select * from users]]>
</queryString>
<field name="userName" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<pageHeader>
<band height="23" splitType="Stretch">
<textField evaluationTime="Page">
<reportElement x="120" y="0" width="238" height="20">
<printWhenExpression><![CDATA[!$V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}
.get("LastPageNumber"))]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["please don't print on last page - page header"]]></textFieldExpression>
</textField>
<textField evaluationTime="Page">
<reportElement x="380" y="0" width="175" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}
.get("LastPageNumber"))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="2" y="2" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["Page header"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="21" splitType="Stretch">
<textField evaluationTime="Page">
<reportElement x="381" y="0" width="174" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}
.get("LastPageNumber"))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{userName}]]></textFieldExpression>
</textField>
<textField evaluationTime="Page">
<reportElement x="119" y="0" width="191" height="20">
<printWhenExpression><![CDATA[!$V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}
.get("LastPageNumber"))]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["please don't print on last page - detail"]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="50">
<line>
<reportElement x="188" y="21" width="100" height="1">
<printWhenExpression><![CDATA[new Boolean($P{REPORT_PARAMETERS_MAP}.put("LastPageNumber",
$V{PAGE_NUMBER}))]]></printWhenExpression>
</reportElement>
</line>
<textField evaluationTime="Page">
<reportElement x="380" y="2" width="174" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["last page variable is: " + $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}
.get("LastPageNumber"))]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
My solution was to make two reports (one for the last page) and then join them (jasperPrints) using the array list option for he jasper exporter:
List jasperPrintList = new ArrayList();
JasperPrint jasperPrint1 =
JasperFillManager.fillReport(
jasperReport1,
parameters,
c
);
JasperPrint jasperPrint2 =
JasperFillManager.fillReport(
jasperReport2,
parameters,
c
);
jasperPrintList.add(jasperPrint1);
jasperPrintList.add(jasperPrint2);
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream byte_report = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "test_report_name");
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, byte_report);
exporter.exportReport();

Related

How to use a postgreSQL crosstab query in Jasper Reports?

I'm trying to make a report in Jasper Reports using a PostgreSQL crosstab query with parameters.
Crosstab query is working when I execute it in pgAdmin 4 with static values. When I copy it into Query dialog in the report builder, and add report parameters, it doesn't work.
Versions:
PostgreSQL server 12
TIBCO Jaspersoft® Studio 6.6.0
Here's the code:
Crosstab query working in pgAdmin 4:
select
cedula,
apellidos,
nombres,
aporteIndividual,
aporteAdicional,
aporteAdicional5,
aporteSeguro,
aporteIndividual::numeric + aporteAdicional::numeric +
aporteAdicional5::numeric + aporteSeguro::numeric as total
from (
SELECT * FROM crosstab
(
'select
p.id,
a.id,
COALESCE (p.primer_apellido, '''') || '' '' ||
COALESCE (p.segundo_apellido, '''') as apellidos,
COALESCE (p.primer_nombre, '''') || '' '' ||
COALESCE (p.segundo_nombre, '''') as nombres,
p.numero_documento,
ad.tipo_aporte,
ad.valor
from
sch_participantes.participante as p,
sch_participantes.aportes as a,
sch_participantes.aporte_detalles as ad
where
p.id = a.id_participe
and a.id = ad.id_aporte
and p.filial = 1084
and p.estado = 1
and a.mes = 1
and a.anio = 2020
order by p.primer_apellido',
'select id from sch_participantes.tipo_aporte ta
order by ta.id'
)
AS
(
id_participe integer,
id_aporte integer,
apellidos text,
nombres text,
cedula text,
aporteIndividual text,
aporteAdicional text,
aporteAdicional5 text,
aporteSeguro text
)
union all
select
p.id,
null,
COALESCE (p.primer_apellido, '') || ' ' ||
COALESCE (p.segundo_apellido, '') as apellidos,
COALESCE (p.primer_nombre, '') || ' ' ||
COALESCE (p.segundo_nombre, '') as nombres,
p.numero_documento,
null,
null,
null,
null
from
sch_participantes.participante as p
where
p.id not in
(
select
a.id_participe
from
sch_participantes.aportes as a
where
a.mes = 1
and a.anio = 2020
)
and p.filial = 1084
and p.estado = 1
) as todo
order by todo.apellidos
and report code:
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="aportes-general" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="da69e8ed-7cd6-42e2-9d96-8f8d86be6137">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="205"/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="786"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="erp_pruebas_michel"/>
<property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w1" value="666"/>
<property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w2" value="320"/>
<parameter name="filial" class="java.lang.Integer" evaluationTime="Early">
<defaultValueExpression><![CDATA[1084]]></defaultValueExpression>
</parameter>
<parameter name="año" class="java.lang.Integer" evaluationTime="Early">
<defaultValueExpression><![CDATA[2020]]></defaultValueExpression>
</parameter>
<parameter name="mes" class="java.lang.Integer" evaluationTime="Early">
<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
</parameter>
<parameter name="crosstab_query" class="java.lang.String" evaluationTime="Early">
<defaultValueExpression><![CDATA["'select" +
" p.id," +
" a.id," +
" COALESCE (p.primer_apellido, '''') || '' '' ||" +
" COALESCE (p.segundo_apellido, '''') as apellidos," +
" COALESCE (p.primer_nombre, '''') || '' '' ||" +
" COALESCE (p.segundo_nombre, '''') as nombres," +
" p.numero_documento, " +
" ad.tipo_aporte," +
" ad.valor" +
" from" +
" sch_participantes.participante as p," +
" sch_participantes.aportes as a," +
" sch_participantes.aporte_detalles as ad" +
" where" +
" p.id = a.id_participe" +
" and a.id = ad.id_aporte" +
" and p.filial = " + $P{filial} +
" and p.estado = 1" +
" and a.mes = " + $P{mes} +
" and a.anio = " + $P{año} +
" order by p.primer_apellido'," +
" 'select id from sch_participantes.tipo_aporte ta" +
" order by ta.id'"]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[select
cedula,
apellidos,
nombres,
aporteIndividual,
aporteAdicional,
aporteAdicional5,
aporteSeguro,
aporteIndividual::numeric + aporteAdicional::numeric +
aporteAdicional5::numeric + aporteSeguro::numeric as total
from (
SELECT * FROM crosstab ($P{crosstab_query})
AS
(
id_participe integer,
id_aporte integer,
apellidos text,
nombres text,
cedula text,
aporteIndividual text,
aporteAdicional text,
aporteAdicional5 text,
aporteSeguro text
)
union all
select
p.id,
null,
COALESCE (p.primer_apellido, '') || ' ' ||
COALESCE (p.segundo_apellido, '') as apellidos,
COALESCE (p.primer_nombre, '') || ' ' ||
COALESCE (p.segundo_nombre, '') as nombres,
p.numero_documento,
null,
null,
null,
null
from
sch_participantes.participante as p
where
p.id not in
(
select
a.id_participe
from
sch_participantes.aportes as a
where
a.mes = $P{mes}
and a.anio = $P{año}
)
and p.filial = $P{filial}
and p.estado = 1
) as todo
order by todo.apellidos]]>
</queryString>
<field name="cedula" class="java.lang.String"/>
<field name="apellidos" class="java.lang.String"/>
<field name="nombres" class="java.lang.String"/>
<field name="aporteIndividual" class="java.math.BigDecimal"/>
<field name="aporteAdicional" class="java.math.BigDecimal"/>
<field name="aporteAdicional5" class="java.math.BigDecimal"/>
<field name="aporteSeguro" class="java.math.BigDecimal"/>
<field name="total" class="java.math.BigDecimal"/>
<background>
<band/>
</background>
<title>
<band height="72">
<frame>
<reportElement mode="Opaque" x="-20" y="-20" width="595" height="92" backcolor="#006699" uuid="0dc47f7a-395a-4b8d-87b4-e927fca8fa61"/>
<staticText>
<reportElement x="20" y="20" width="410" height="30" forecolor="#FFFFFF" uuid="3c6488eb-bfbc-4fb6-b9b2-3637a1cf0c9d"/>
<textElement>
<font size="19" isBold="true"/>
</textElement>
<text><![CDATA[Reporte general de aportes]]></text>
</staticText>
<textField>
<reportElement x="20" y="50" width="300" height="30" forecolor="#FFFFFF" uuid="4a131c99-d637-4199-9335-493f0e7a7750"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA["Período:" + $P{mes} + "-" + $P{año}]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band height="13"/>
</pageHeader>
<columnHeader>
<band height="18">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.spreadsheet.SpreadsheetLayout"/>
<staticText>
<reportElement x="0" y="0" width="50" height="18" uuid="4d23b483-a6f5-44f1-b4b0-e0c92d8736b0">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="fdf238bc-d6fa-41f7-a846-a09be881e2a8"/>
</reportElement>
<text><![CDATA[cedula]]></text>
</staticText>
<staticText>
<reportElement x="50" y="0" width="130" height="18" uuid="b2c90d08-f6a7-441c-92c3-3487aed4a04f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="87c434fd-7660-4c3e-8ca4-97bb9499349b"/>
</reportElement>
<text><![CDATA[apellidos]]></text>
</staticText>
<staticText>
<reportElement x="180" y="0" width="120" height="18" uuid="4aca3646-0e0e-4253-83f3-7903cb60b048">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="289c8d74-6077-45d8-9373-c238a4598284"/>
</reportElement>
<text><![CDATA[nombres]]></text>
</staticText>
<staticText>
<reportElement x="300" y="0" width="50" height="18" uuid="3e268eea-8ecb-4fb1-8bfe-6f99f39caccb">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8d1cedc0-4fd2-4f06-8725-b17630f08437"/>
</reportElement>
<text><![CDATA[aporteIndividual]]></text>
</staticText>
<staticText>
<reportElement x="350" y="0" width="50" height="18" uuid="5f5e3710-7eef-48c5-a962-6120bb9fa67b">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="fa8014b3-1b03-4443-bf80-167703b8f1cb"/>
</reportElement>
<text><![CDATA[aporteAdicional]]></text>
</staticText>
<staticText>
<reportElement x="400" y="0" width="50" height="18" uuid="00653733-6788-45b6-ab57-d37d12293a6d">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d066fefc-d2fb-49b9-bde1-f706ea220cb9"/>
</reportElement>
<text><![CDATA[aporteAdicional5]]></text>
</staticText>
<staticText>
<reportElement x="450" y="0" width="50" height="18" uuid="cf37f752-5ba2-4950-8200-099943713cd7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="e434b3c8-20bc-4631-b59b-a4939675978f"/>
</reportElement>
<text><![CDATA[aporteSeguro]]></text>
</staticText>
<staticText>
<reportElement x="500" y="0" width="50" height="18" uuid="623db75c-ff28-4aab-8fc3-190f479cd8c5">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5cd0ec9d-c45b-4e7b-9fbc-2bb616521f0e"/>
</reportElement>
<text><![CDATA[total]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="30">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.spreadsheet.SpreadsheetLayout"/>
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="2a352a63-f1fe-4a2e-bb74-937d2e3f335b">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="fdf238bc-d6fa-41f7-a846-a09be881e2a8"/>
</reportElement>
<textFieldExpression><![CDATA[$F{cedula}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="50" y="0" width="130" height="30" uuid="970896d3-426b-41f2-b097-784d83a2e172">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="87c434fd-7660-4c3e-8ca4-97bb9499349b"/>
</reportElement>
<textFieldExpression><![CDATA[$F{apellidos}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="0" width="120" height="30" uuid="0c2e4d66-7faa-4baa-a77a-dfbe60dfe466">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="289c8d74-6077-45d8-9373-c238a4598284"/>
</reportElement>
<textFieldExpression><![CDATA[$F{nombres}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="300" y="0" width="50" height="30" uuid="0c6e4a8e-5b0e-4a07-9d73-282781817c95">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8d1cedc0-4fd2-4f06-8725-b17630f08437"/>
</reportElement>
<textFieldExpression><![CDATA[$F{aporteIndividual}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="350" y="0" width="50" height="30" uuid="d2af8ebf-cbc9-407e-8dbe-f1af49525966">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="fa8014b3-1b03-4443-bf80-167703b8f1cb"/>
</reportElement>
<textFieldExpression><![CDATA[$F{aporteAdicional}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="400" y="0" width="50" height="30" uuid="a78a3c65-c069-447d-a3ae-84087e3f4977">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d066fefc-d2fb-49b9-bde1-f706ea220cb9"/>
</reportElement>
<textFieldExpression><![CDATA[$F{aporteAdicional5}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="450" y="0" width="50" height="30" uuid="5f22b066-53b8-47dd-b2c9-bb026eb69dae">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="e434b3c8-20bc-4631-b59b-a4939675978f"/>
</reportElement>
<textFieldExpression><![CDATA[$F{aporteSeguro}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="500" y="0" width="50" height="30" uuid="1f698fc0-da4d-4aa9-b21e-6ba74dfe8df0">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5cd0ec9d-c45b-4e7b-9fbc-2bb616521f0e"/>
</reportElement>
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="17">
<textField>
<reportElement mode="Opaque" x="0" y="4" width="515" height="13" backcolor="#E6E6E6" uuid="0b71f3fa-21ce-4aa4-8fbc-84c015c403e3"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement mode="Opaque" x="515" y="4" width="40" height="13" backcolor="#E6E6E6" uuid="837ccbf7-57ea-4894-a13f-415d2472630f"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="0" y="4" width="100" height="13" uuid="ae716933-1e7e-4a7c-b470-d58ad1afcd72"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="47">
<staticText>
<reportElement x="270" y="0" width="100" height="30" uuid="5042bbb1-6dc0-4b69-a4f6-49f75dc42a25"/>
<text><![CDATA[Total Aportes]]></text>
</staticText>
</band>
</summary>
</jasperReport>
When I execute preview, I get this syntax error:
Caused by: org.postgresql.util.PSQLException: ERROR: error de sintaxis
en o cerca de «'select p.id, a.id, COALESCE (p.primer_apellido,
'''') || '' '' || COALESCE (p.segundo_apellido, '''') as
apellidos, COALESCE (p.primer_nombre, '''') || '' '' || COALESCE
(p.segundo_nombre, '''') as nombres, p.numero_documento,
ad.tipo_aporte, ad.valor from sch_participantes.participante as
p, sch_participantes.aportes as a,
sch_participantes.aporte_detalles as ad where p.id = a.id_participe
and a.id = ad.id_aporte and p.filial = 1084 and p.estado = 1
and a.mes = 1 and a.anio = 2020 order by p.primer_apellido'» at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273) at
net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:310)
... 6 more
For testing purposes, I replaced the SQL query with a fixed crosstab inner query like this:
<queryString language="SQL">
<![CDATA[select
cedula,
apellidos,
nombres,
aporteIndividual,
aporteAdicional,
aporteAdicional5,
aporteSeguro,
aporteIndividual::numeric + aporteAdicional::numeric +
aporteAdicional5::numeric + aporteSeguro::numeric as total
from (
SELECT * FROM crosstab (
'select
p.id,
a.id,
COALESCE (p.primer_apellido, '''') || '' '' ||
COALESCE (p.segundo_apellido, '''') as apellidos,
COALESCE (p.primer_nombre, '''') || '' '' ||
COALESCE (p.segundo_nombre, '''') as nombres,
p.numero_documento,
ad.tipo_aporte,
ad.valor
from
sch_participantes.participante as p,
sch_participantes.aportes as a,
sch_participantes.aporte_detalles as ad
where
p.id = a.id_participe
and a.id = ad.id_aporte
and p.filial = 1084
and p.estado = 1
and a.mes = 1
and a.anio = 2020
order by p.primer_apellido',
'select id from sch_participantes.tipo_aporte ta
order by ta.id'
)
AS
(
id_participe integer,
id_aporte integer,
apellidos text,
nombres text,
cedula text,
aporteIndividual text,
aporteAdicional text,
aporteAdicional5 text,
aporteSeguro text
)
union all
select
p.id,
null,
COALESCE (p.primer_apellido, '') || ' ' ||
COALESCE (p.segundo_apellido, '') as apellidos,
COALESCE (p.primer_nombre, '') || ' ' ||
COALESCE (p.segundo_nombre, '') as nombres,
p.numero_documento,
null,
null,
null,
null
from
sch_participantes.participante as p
where
p.id not in
(
select
a.id_participe
from
sch_participantes.aportes as a
where
a.mes = $P{mes}
and a.anio = $P{año}
)
and p.filial = $P{filial}
and p.estado = 1
) as todo
order by todo.apellidos]]>
</queryString>
and the report preview executed well.
Any advice is truly appreciated.
JasperReports translates $P{..} in report queries to JDBC prepared statement parameters. That is, if you have WHERE column = $P{..} in the report query, the report will run WHERE column = ? as a prepared statement with the report parameter value sent as statement parameter.
Prepared statement parameters stand for single values in the query, so crosstab($P{..}) will not work, even if the parameter values contains a comma. What might work is crosstab($P{first_query}, $P{second_query}), just note that prepared statement parameters are provided as raw values so you should not enclose the values in quotes or escape quotes inside the values.
But if you just want to textually insert the parameter value in the query, you can use $P!{..} instead of $P{..}. Since the parameter value in your report looks like a query fragment, using SELECT * FROM crosstab ($P!{crosstab_query}) in the report query should work.

How to do form block letter printing?

I want to print in block letters in a jasper print. E.g. I have a Bank Format and I want the name to come in the boxes. How does one do that?
Name: [F][I][R][S][T][ ][N][A][M][E]
Option1 - Print cell by cell with a ${FIRST_NAME}.charAt(x) - which is unsustainable
Option2 - Add spaces between characters but this changes based on font size
Option3 - Add padding spaces to the end of the text. Stretch the text to the full width available and characters get distributed equally - how does one do this?
This is normal achieved using a monospaced font.
If you like to achieve it with other fonts or the spacing is very large you can use a subreport (that is called every time you need the fixed space)
Example
Main report (I'm using parameter to test)
Call the subreport with a datasource that contains each letter, I'm using $P{testText}.split("") , since char[] is not allowed in the JRBeanArrayDataSource.
Note: split will give empty first String in java7 but not in java8
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="MainFixedSpace" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d2bcb5ab-c751-4f39-8753-561b8a6ac629">
<parameter name="testText" class="java.lang.String">
<defaultValueExpression><![CDATA["Hello world"]]></defaultValueExpression>
</parameter>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\jdd\\projects\\StackTrace\\jasper\\"]]></defaultValueExpression>
</parameter>
<title>
<band height="25" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="25" uuid="76f53ca9-da1f-46c8-bb3b-aca0dc43d2d3"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanArrayDataSource($P{testText}.split(""))]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "MainFixedSpace_subreport.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
</jasperReport>
Subreport
Setup the the fixed space column count in my case 20 columns on each row (you need to adapted it to your case) and set printOrder="Horizontal" The _THIS field will let you access the letter.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="MainFixedSpace_subreport" columnCount="20" printOrder="Horizontal" pageWidth="555" pageHeight="802" columnWidth="27" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="77ba37de-32e1-4ec6-8496-58d716d0340d">
<field name="_THIS" class="java.lang.String"/>
<detail>
<band height="25" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="27" height="25" uuid="ffb27000-41ba-419f-8836-b24dbb0dbb25"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{_THIS}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
Output

How to add bullet point in TextField

I want to add bullet point to my static text and to a text field, i added style tag to the jrxml but it didn't work for me :
Here's the example :
TextField :
<textField isBlankWhenNull="true">
<reportElement uuid="cfd514bc-d1c5-4369-b10d-71042b046e37" x="11" y="0" width="400" height="12"/>
<textElement/>
<textFieldExpression><![CDATA[<style size="40">.</style>$F{LMSG}]]></textFieldExpression>
</textField>
StaticText:
<staticText>
<reportElement uuid="c1485aba-09a4-4c7b-9106-0893341f1368" x="44" y="107" width="309" height="15"/>
<textElement>
<font size="9"/>
</textElement>
<text><![CDATA[<style size="40">.</style>Je déduis cet avoir de ma commande]]></text>
</staticText>
You can use styled markup.
Try to use <li> tag.
The sample
The jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="bullet_sample" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="aa7ced41-689a-4b8d-94aa-ee79c243a7a8">
<title>
<band height="79" splitType="Stretch">
<textField>
<reportElement uuid="bf39def6-a3a7-4fa1-9e99-e488b3567974" x="159" y="31" width="100" height="20"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA["<li>Text with bullet</li>"]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
The result will be (via preview in iReport):
In case using field, the right expression will be:
<textField>
<reportElement x="171" y="0" width="100" height="20"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA["<li>" + $F{fieldName} + "</li>"]]></textFieldExpression>
</textField>
Note:
You can find more info about styled text in Style a text field in JasperReports post and in Styled Text sample
I used the <li> tag, but it introduced padding which did not look good. So, I used "\u2022" which gives a round symbol like
<textFieldExpression><![CDATA["\u2022 Line1\n\u2022 Line2"]]></textFieldExpression>
So, this looks much cleaner

How to get the workflow authentication to work in Aviarc

We are trying to roll out authentication into my app and it’s not working for us.
We have set up the Current Authority and Current Authorizer and have even set the login query to be just select ‘a’ so we are guaranteed to get a result set.
We have copied the Login workflow to workflows/system directory.
It doesn’t look like it’s even trying to run the login query.
start.xml workflow:
<workflow>
<authenticate error-screen="login-error" dataset="login">
<show-screen name="login" />
</authenticate>
<call-workflow name="home"/>
</workflow>
login.xml screen:
<screen xmlns:action="urn:aviarc:widget:com.aviarc.toronto.widget.core.action:1"
xmlns:app="urn:aviarc:widget:application">
<group-box visible="y" left="10" right="4" top="10" bottom="4" class="blue">
<image height="80" width="245" left="10" top="5" class="mfcologo" />
<line height="5" left="0" right="0" top="120" class="myerblue" />
<text-static visible="y" left="74" top="151" width="80" height="20" text="User name:" />
<text-static visible="y" left="234" top="151" width="80" height="20" text="Password:" />
<text-edit name="username" left="74" top="182" width="100" height="20" field="login.user_name" />
<text-edit name="password" left="234" top="182" width="100" height="20" field="login.user_password" datatype="password" />
<button left="376" top="182" width="60" height="20" label="Login" action="Next"/>
</group-box>
</screen>
system/Login.xml workflow:
<workflow xmlns:au-security="urn:aviarc:xmlcommand:au.com.aviarc.xmlcommand.security">
<au-security:hash-text text="{$login.user_password}" result-field="login.hashed-password" />
<dataset name="cslogin" databroker="loginqry" query="get-all">
<param name="username" value="{$login.user_name}" />
<param name="password" value="{$login.hashed-password}" />
</dataset>
<if test="dataset-empty" value1="cslogin">
<then>
<set-field field="login.authenticated" value="n"/>
</then>
<else>
<set-field field="login.authenticated" value="y"/>
</else>
</if>
</workflow>
The Workflow authentication requires "username" field to be populated prior to entering it, otherwise the authentication would fail immediately and login error screen will be displayed.
In your example it is fairly easy to fix, changing the line in login.xml screen from:
<text-edit name="username" left="74" top="182" width="100" height="20" field="login.user_name" />
to be:
<text-edit name="username" left="74" top="182" width="100" height="20" field="login.username" />
and updating reference to it in the system/Login workflow.

How to embed and display an SVG image in iReport

I am using iReport 4.5.0, and want to embed an SVG image to generate a PDF.
When using iReport's preview option to run the report, the image won't get rendered to the PDF (i.e. there's an empty space where the image is supposed to be).
I do not see any exceptions in the logs during execution, what's going on?
Here's the image tag code snippet:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="reportSVGTest" language="groovy" pageWidth="595"
pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20"
topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="50">
<staticText>
<reportElement x="81" y="13" width="100" height="20"/>
<textElement/>
<text><![CDATA[Hello]]></text>
</staticText>
</band>
</title>
<detail>
<band height="443" splitType="Stretch">
<image hAlign="Center" vAlign="Middle" isUsingCache="true" isLazy="true">
<reportElement x="12" y="17" width="512" height="403"/>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable">
<![CDATA[
net.sf.jasperreports.renderers.BatikRenderer.getInstance(
new java.io.File("C:\\Users\\akshayd\\Desktop\\polygons1.svg"))
]]>
</imageExpression>
</image>
</band>
</detail>
</jasperReport>
I wanted to embed a SVG text in my report, and this topic helped me succeed.
I am using Jaspersoft Studio with full support for JasperReports 5.5.0.
Here is how i did :
Create a image element
Choose Custom expression and let expression empty
Modify JRXML source: add a tag imageExpression in the tag image
<image>
<reportElement x="0" y="60" width="50" height="50" uuid="c0d0856e-0bb1-4634-b8b0- 6f7ace0e3ff3"/>
<imageExpression><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstanceFromText("<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.0\" width=\"88\" height=\"21\" id=\"svg\"><svg:g id=\"layer1\"><svg:path id=\"path1\" d=\"M 61.799149,2.0342178 L 67.119461,2.0342178 L 67.119461,19.213905 L 61.799149,19.213905 L 61.799149,2.0342178 z\" style=\"text-anchor:start;fill:#FF0000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;\" /></svg:g> </svg:svg>")]]></imageExpression>
</image>
So, i use the method getInstanceFromText of BatikRenderer.
Do not forget to protect double quotes in your SVG text.