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

How to use scriptlets?


binmaker

Recommended Posts

Hi.

I have two things to do and I think I've got to use scriptlet.

But I don't know  how to use scriptlets in iReport.

One of both, I have to print a row count every row in a detail band.

For this, I made a variable and placed it in a detail band. To count this variable, I think I have to use scriptlet. Is it right?

Another thing I have to do is controlling a line height.

I placed a line element in detail band to indicate a bottom of a row and I'd like to change a height of the line every 5 rows.

Please, let me know how to use scriptlets.

Thank you.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You don't need to use scriptlets to display the record count as there is an inbuilt system variable that counts records for you: $V(REPORT_COUNT)

Simply set up a text box with $V(REPORT_COUNT} as the control source  in the Detail band and you're done.   

 

  <textField hyperlinkType="None">
    <reportElement x="413" y="12" width="100" height="20"/>
    <textElement/>
    <textFieldExpression class="java.lang.Integer">

       <![CDATA[$V{REPORT_COUNT}]]>

    </textFieldExpression>
   </textField>

 

As for the line height, can you post an example of what you want to do   (eg. make every fifth line double the height)

Link to comment
Share on other sites

You can also use the REPORT_COUNT variable to control your line thickness.  You can't do it directly though, because the pen thickness attribute is a static value.

You can set up two lines in the detail section of your report, stacked on top of each other.  Set the pen weight on each line statically or using a style.  Then use the PrintWhen expression to control when the thick line is displayed.  The thin line will also be displayed when the thick line is displayed, but it doesn't matter because they have the same origin and width.  

  <line>
    <reportElement style="thin_line" x="0" y="20" width="555" height="1" backcolor="#FFFFFF">
    </reportElement>
   </line>
   <line>
    <reportElement style="thick_line" x="0" y="21" width="555" height="1" backcolor="#FFFFFF">
     <printWhenExpression><![CDATA[new java.lang.Boolean(new java.lang.Integer($V{REPORT_COUNT}.intValue()% 5).equals(new java.lang.Integer(0)))]]></printWhenExpression>
    </reportElement>
   </line>

 

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