Jump to content
We've recently updated our Privacy Statement, available here ×

Default parameters - still needed to pass?


pawel_r

Recommended Posts

Hi

I came across following problem - if I try to produce report, which contains soe parameters (all with default value set) JasperFillManager.fillReport doesn't fill report properly (it produces empty report). It wouldn't be a problem for me if there was some kind of exception thrown - which didn't happen. The servlet was working with no visible problem but all reports were generated empty.

It happens if I one of parameters is not supplied in parameter Map(also when Map is empty or null is provided insted of Map parameter)

 

I am using jasperreports engine in version 3.5.3



Post Edited by pawel_r at 08/26/2009 07:19
Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

The most important part here is (AFAIK)

 

<parameter name="START_DATE" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="END_DATE" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="REPORT_TYPE" class="java.lang.String">
        <defaultValueExpression><![CDATA["M"]]></defaultValueExpression>
    </parameter>

 

In attachment there is the whole jrxml file (without SQL query)

Link to comment
Share on other sites

If you say so... I was quite sure that problem lies not in SQL query.

 

Thank you for your patience

Code:
SELECT     chre.TYPE AS chre_TYPE,	(Select count(chre2.id)  from change_requests_h chre2 where chre2.id=chre.id) as "Liczba zmian",        (Select count(chre2.id) from change_requests_h chre2 where         (Select valid_from from change_requests_h Where executed_action = 'ZAMKNIECIE_ZMIANY' And change_requests_h.id = chre2.id) <= chre2.on_prod_introduction_date and chre2.id=chre.id group by chre2.id) as "Liczba zmian terminowych",     chre.BUSINESS_ID AS chre_BUSINESS_ID,     chre.TITLE AS chre_TITLE,     SYSTEM_USERS.DISPLAY_NAME AS SYSTEM_USERS_DISPLAY_NAME,     PROCESS_STAGES.NAME AS PROCESS_STAGES_NAME,     chre.ID AS chre_ID,     chre.ON_PROD_INTRODUCTION_DATE,     USER_GROUPS.NAME AS USER_GROUPS_NAME,	MY_DATA.NAME,        MY_DATA_SOJOURNS.entry_timestamp,        MY_DATA_SOJOURNS.EXIT_TIMESTAMP,        MY_DATA_SOJOURNS.DUE_DATEFROM     MY_DATA MY_DATA INNER JOIN MY_DATA_SOJOURNS MY_DATA_SOJOURNS ON MY_DATA.ID = MY_DATA_SOJOURNS.PRST_ID     INNER JOIN CHANGE_REQUESTS chre ON MY_DATA_SOJOURNS.ID = chre.PRIN_ID     INNER JOIN USER_GROUPS USER_GROUPS ON chre.USGR_ID = USER_GROUPS.ID     INNER JOIN SYSTEM_USERS SYSTEM_USERS ON chre.SYUS_ID_PM=SYSTEM_USERS.ID     INNER JOIN DATA_STAGES DATA_STAGES ON MY_DATA.PRSG_ID = DATA_STAGES.ID WHERE     chre.type IN ('DEVELOP_STANDARD','DEVELOP_SHORT_PATH')ANDchre.ON_PROD_INTRODUCTION_DATE between $P{START_DATE} and $P{END_DATE} AND  chre.ON_PROD_INTRODUCTION_DATE between $P{START_DATE} and $P{END_DATE}order by chre.type
Link to comment
Share on other sites

Hi,

 

If you don't supply values for your START_DATE and END_DATE parameters, they will be initialized with the current datetime, because of the defaultValueExpression you used for them.

So basically, start date and end date will be equal. Let's say current datetime is something like:

 

2009-08-31 11:33:42

 

Do you have records in your database in which ON_PROD_INTRODUCTION_DATE is precisely equal to this time?

I'm pretty sure you don't, and that's why your report is empty. If you don't like it to be empty when no records correspond to your filter criteria, use whenNoDataType="AllSectionsNoDetail".

 

 

You might want to use the $!P{} syntax to alter the query in case parameters are missing. You'll need to read more documentation or at least look into the /demo/samples/query samples provided with the JR project package.

 

Thank you,

Teodor

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...