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

Conditional Style and external parameters


mferretti

Recommended Posts

I have created a parameter ( java.util.Date ) and used it in a conditional style : $V{upload_date}.equals( $P{endDate} )

 When I try to preview the report I get the following : 

Compiling to file... /home/ferrema/Liferay-Portal/workspace/Plugins SDK/portlets/jasper-portlet/docroot/reports/Upload_Activity.jasper net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 
     1. Parameter not found : endDate
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:258)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:140)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:131)
    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:514)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

 

 

 

Is there a way to use external parameters with conditional styles ? 

 

TIA

 

Marco 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Not sure what the problem is.  I just whipped up a quick report that took an "endDate" parameter as input and then did a SQL query of my database, highlighting my two output detail fields for every record where the OPEN_DATE field matched the $P{endDate} parameter, and it seems to have worked fine.  My jrxml is pasted below, and the resulting PDF (the highlighted bits are on page two) is attached.  Good luck!

Carl

Code:


Post Edited by cbarlow3 at 12/14/2010 17:34
Link to comment
Share on other sites

 thanks for your reply and the time you took to test this . 

 

I did remove the parameter and the style and run the report : succeded

then I tried re-inserting : 

added the parameter : ok

added the style : ok 

 

this time i worked on the xml directly ...... 

 

Then I modified the style and re-run the preview ... and got the error again. 

if I do the remove/add described above it starts working again ... 

Could this be an iReport problem (some kind of unexpected state ) ?



Post Edited by mferretti at 12/15/2010 10:08



Post Edited by mferretti at 12/15/2010 10:11
Link to comment
Share on other sites

 Ok solved. 

 

Maybe I should have mentioned that the style was to be applied to a crosstab ... since that's the problem !! As far as I have understood, crosstabs do not have access to report's parameters thus I had to create a measure and assign the parameter value to it. Then it was a matter of changing the style evaluation function and there u go !!  :

parameter : 

<parameter name="endDate" class="java.util.Date">                                                                                                            <defaultValueExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy").parse("06/06/2010")]]></defaultValueExpression>      </parameter>

measure :

 
<measure name="endDateMeasure" class="java.util.Date">
   <measureExpression><![CDATA[$P{endDate}]]></measureExpression>
</measure>
 
style : 
<style name="CrosstabCell" mode="Opaque" forecolor="#FFFFFF" backcolor="#FFFFFF" hAlign="Center" vAlign="Middle" isBlankWhenNull="false">
<conditionalStyle>
<conditionExpression><![CDATA[$V{upload_date}.before( $V{endDateMeasure} )]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="#00A000" isBlankWhenNull="false"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$V{upload_date}.after( $V{endDateMeasure} )]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="#C80000" isBlankWhenNull="false"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$V{upload_date}.equals( $V{endDateMeasure} )]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="#00A000" isBlankWhenNull="false" />
</conditionalStyle>
</style>
 
Link to comment
Share on other sites

  • 5 months later...

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...