Jump to content
Changes to the Jaspersoft community edition download ×

$P{REPORT_SCRIPTLET} is not convenient to use


2005 IR Help

Recommended Posts

By: Goh S H - shgoh

$P{REPORT_SCRIPTLET} is not convenient to use

2005-02-02 08:19

Scriptlet is currently cast to net.sf.jasperreports.engine.JRAbstractScriptlet when

reference it using $P{REPORT_SCRIPTLET}, any extra methods in the scriptlet is not

accessible unless manually cast to scriptlet class, e.g.:

 

((my_reportScriptlet)$P{REPORT_SCRIPTLET}).my_method()

 

But the above is not valid when "Use iReport internal scriptlet support" option is selected,

as the class name is managed by iReport -> <ScriptletClassName>

 

In short, $P{REPORT_SCRIPTLET} should be cast to <ScriptletClassName> instead of

net.sf.jasperreports.engine.JRAbstractScriptlet to make it useful.

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: $P{REPORT_SCRIPTLET} is not convenient to use

2005-02-02 15:49

 

Yes and no.

 

When you "Use iReport internal scriptlet support", the scriptlet of the report extends IReportScriptlet, that provide a set of methods useful for creating charting series.

 

I plan to provide a ReportUtility class that permit to use in the expressions a semplified syntax like:

 

ReportUtility.functionXYZ( ... )

 

whitout refer to the scriptlet.

In this ReportUtility will be a lot of methods like:

setMapVal()

addToSeries()

getSeries()

readBlobField()

compareDates()

formatNumber()

ltrim()

rtrim()

trim()

sum()

....

 

Giulio

 

 

 

 

 

By: Goh S H - shgoh

RE: $P{REPORT_SCRIPTLET} is not convenient to

2005-02-03 08:05

Great to have ReportUtility class :-)

 

But how do I call my own method in the scriptlet?

I wish i can call my method in this way:-

 

$P{REPORT_SCRIPTLET}.my_method()

 

which is more readable and meaningful.

 

Maybe this request should belong to jasperreport?

as it responsible to compile the .jrxml to .jasper?

 

Regards,

Goh

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: $P{REPORT_SCRIPTLET} is not convenient to use

2005-02-04 03:19

 

The name of the scriptlet is the same of the report.

If your report is namer MyReport.jrxml, you have to use this syntax:

 

((MyReportScriptlet)$P{REPORT_SCRIPTLET}).my_method()

 

Please note: the scriptlet name is the report name with the suffix "Scriptlet".

 

Giulio

Link to comment
Share on other sites

  • 3 months later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Guilio,

 

If I do this

 

((MyReportScriptlet)$P{REPORT_SCRIPTLET}).my_method()

 

the I get the following error:

 

java.lang.ClassCastException:Ânet.sf.jasperreports.engine.JRDefaultScriptlet ÂÂÂÂatÂcompanyDataSheetReport_certifications_1166409939336_195713.evaluate(companyDataSheetReport_certifications_1166409939336_195713:231) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:186)

 

Do you have any other ideas?

 

Matt

Link to comment
Share on other sites

1)Create scriptlet class and make it place inside the web-inf/classes/<packagename>

Inside the scriptlet class,

for example:

 

package <pagename>;

import net.sf.jasperreports.engine.JRDefaultScriptlet;

import net.sf.jasperreports.engine.JRScriptletException;

 

public class sample extends JRDefaultScriptlet{

public String hello(){

return "hello how r u ? ";

}

 

 

}

 

2)In i-report,select ReportProperties--> Scriptlettab--> ScriptletClass --> Use this scriptlet class

on next field,give the <packagename>.<scriptletclassname>

 

3)In textField,call the method of scriptletclass as

$P{REPORT_SCRIPTLET}.<methodname> . for example : $P{REPORT_SCRIPTLET}.hello()

 

4) Before compiling the report,go to options ---> classpath --> Add Folder to web-inf/classes

 

5) copy the tools.jar(available in jdk1.5/lib) and paste it on jasperreport lib folder.

Link to comment
Share on other sites

  • 1 month later...

Hi

This is Atanu. I am very new in ireport and also in java environment. In the ireport I have designed a template .like this.

please look on attach file

size=150C:Documents and SettingsAtanuMy Documentsgraph.JPEG[/img]

Now I want to plot a line graph on the basis of the each data like t1 t2 ---t5 and lcl, ucl, actual value for each row.

That I have done. Now my problem is that I have to change the color of points of t1 t2 ---t5 on the basis of Lcl and Ucl . If the value of t1 ,or t2 or ----t5 are between Ucl and Lcl the color will be blue. And if it out side of Lcl and Ucl then it will be red..

I want the following figure. Where the upper bold line is Ucl and lower bold line isLcl

size=150C:Documents and SettingsAtanuMy Documentsdata.JPEG[/img]

Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it .

 

Code:

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.JREmptyDataSource;
import java.util.*;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import javax.sql.*;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.*;
import org.jfree.chart.renderer.*;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.LevelRenderer;
import org.jfree.chart.renderer.category.LayeredBarRenderer;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import java.lang.String;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRChartPlot;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.axis.CategoryLabelPositions;


import org.jfree.chart.renderer.category.LineRenderer3D;
import java.awt.*;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;
import org.jfree.chart.JFreeChart;
import net.sf.jasperreports.engine.*;
import java.awt.Color;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer3D;
import java.lang.Object;



public class LineChartCustomizer extends JRAbstractChartCustomizer {

public void customize(JFreeChart chart, JRChart jasperChart) {

LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();


renderer.setSeriesPaint(1, Color.green);
renderer.setSeriesPaint(4, Color.orange);

chart.setTitle("Setting the title "«»);
}


}

Now this customize class ok running successfully with creating jar files.

Now I want to create a logic to check the value of t1 t2 t3 t5 with respect to UCL and LCL. How can I fetch data from report.

Or is there any other way to do this.

Is there any way to pass value from iReport to customizer class ?

 

What should I do. Please please help me. It’s urget for me.

 

Any help would be greatly appreciated.

Thanks in advance.

[file name=query-37ab101e3a539a71be9c962f72749d92.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-37ab101e3a539a71be9c962f72749d92.doc[/file]

Post edited by: atanupanda, at: 2007/02/06 10:05

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