Jasper report with optional parameter has no pages

Questions and answers on developing, deploying and using plugins and JavaBeans

Jasper report with optional parameter has no pages

Postby deezzub » Fri Dec 06, 2013 3:24 pm

I have a Jasper report with a optional parameter $P!{withVessel} that is used in the report query.:

Code: Select all
SELECT
     tckopf."VONNAME" AS tckopf_VONNAME,
     tckopf."ANNAME" AS tckopf_ANNAME,
     tckopf."SCHIFF" AS tckopf_SCHIFF,
     tckopf."VON" AS tckopf_VON,
     tckopf."BIS" AS tckopf_BIS,
     tckopf."TAGE" AS tckopf_TAGE,
     tckopf."ID" AS tckopf_ID,
     tckopf."PERIODE" AS tckopf_PERIODE,
     tckopf."BEZAM" AS tckopf_BEZAM
FROM
     "tckopf" tckopf
WHERE
     tckopf."ANMAND"= $P{customerNo}  AND tckopf."VONMAND"= $P{clientNo} $P!{withVessel}


withVessel is defined as java.lang.String with the following "Default Value Expression".:

Code: Select all
$P{vesselNo} == null ? "" : " and tckopf.VESSEL_NR=' "+ $P{vesselNo} + " ' "


The parameter vesselNo is defined as java.lang.Integer and is used as prompt in iReport.

If I compile the report in iReport with and without a passed vesselNo, the report is showed as desired. But if I run the report from Servoy, it is only showed as desired if the vesselNo is not passed to the report. If I pass the vesselNo to the report, I get a message.:

The document has no pages


This is the code that calls the report.:
Code: Select all
   reportParams.clientNo = forms.boss_char_charterfaktura_base_dtl.vonmand;
   reportParams.customerNo = forms.boss_char_charterfaktura_base_dtl.anmand;
   if ( withVessel ) {
      reportParams.vesselNo = forms.boss_char_charterfaktura_base_dtl.vessel_nr;
   } else {
      reportParams.vesselNo = null;
   }

   report = plugins.jasperPluginRMI.runReport( db.DATABASE.BOSS_DB, charterFakturaDocListReport, null, "view", reportParams, forms.boss_char_charterfaktura_base_dtl.getDocumentLanguage( ) );


    iReport version: 4.0.1
    Servoy JasperReports Plugin version: 4.0.1

Why it does not work if I pass the vesselNo to the report from Servoy?
Last edited by deezzub on Fri Dec 06, 2013 3:59 pm, edited 1 time in total.
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Jasper report with optional parameter has no pages

Postby jasantana » Fri Dec 06, 2013 3:34 pm

Try this:

Code: Select all
SELECT
     tckopf."VONNAME" AS tckopf_VONNAME,
     tckopf."ANNAME" AS tckopf_ANNAME,
     tckopf."SCHIFF" AS tckopf_SCHIFF,
     tckopf."VON" AS tckopf_VON,
     tckopf."BIS" AS tckopf_BIS,
     tckopf."TAGE" AS tckopf_TAGE,
     tckopf."ID" AS tckopf_ID,
     tckopf."PERIODE" AS tckopf_PERIODE,
     tckopf."BEZAM" AS tckopf_BEZAM
FROM
     "tckopf" tckopf
WHERE
     tckopf."ANMAND"= $P{customerNo}  AND tckopf."VONMAND"= $P{clientNo}
     AND (tckopf.VESSEL_NR=$P{vesselNo} OR $P{vesselNo} IS NULL)
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Jasper report with optional parameter has no pages

Postby deezzub » Fri Dec 06, 2013 4:07 pm

jasantana wrote:Try this:

Code: Select all
SELECT
     tckopf."VONNAME" AS tckopf_VONNAME,
     tckopf."ANNAME" AS tckopf_ANNAME,
     tckopf."SCHIFF" AS tckopf_SCHIFF,
     tckopf."VON" AS tckopf_VON,
     tckopf."BIS" AS tckopf_BIS,
     tckopf."TAGE" AS tckopf_TAGE,
     tckopf."ID" AS tckopf_ID,
     tckopf."PERIODE" AS tckopf_PERIODE,
     tckopf."BEZAM" AS tckopf_BEZAM
FROM
     "tckopf" tckopf
WHERE
     tckopf."ANMAND"= $P{customerNo}  AND tckopf."VONMAND"= $P{clientNo}
     AND (tckopf.VESSEL_NR=$P{vesselNo} OR $P{vesselNo} IS NULL)



Thanks, your solution does it. :) Do you know, why the other does not work?
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: Jasper report with optional parameter has no pages

Postby jasantana » Fri Dec 06, 2013 4:11 pm

Print in the report the value for $P{vesselNo} I guess the only reason not to work is that it has a value which is not null
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Jasper report with optional parameter has no pages

Postby vincentc » Fri Feb 20, 2015 3:25 pm

Thank you jasantana, you save me from the madness, I had the same problem and I was just going crazy with it ... Your solution works perfectly fine.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am


Return to Plugins and Beans

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron