Jump to content
JasperReports Library 7.0 is now available ×

Help for using Parameters


ktrinad

Recommended Posts

By: Miko Yung - hly

Help for using Parameters

2003-04-29 16:39

Hi all,

 

I just started using ireport and is having some troubles figure out how to use some of features it has. I am just wondering how can i create a paramter to allow the user to input a value in?? And one more question, how do create a sum expression to calculate for Totals?

 

thank you very much for your help

Jennie

 

 

 

 

By: Ratchapong - jeng

RE: Help for using Parameters

2003-04-29 19:59

Hi,

 

The parameter "?" must be passing by using the following code ...

 

Map parameters = new HashMap();

parameters.put("ReportTitle", "Just Report Name");

parameters.put("myParaeter", "This is Value");

 

And you can set default value to make report pass that value first...

 

Sum Expression can be done 2 ways (All i know now...)

First, add new variable then

-set calculation type to Sum,

-Variable Type set to the data type that you are using (Integer,float, whatever that are number) and following by

-set the field name in Expression box that you want to sum.

-Now use this variable in the report. It will automatically Sum your data.

NOTE: If you put it in detail band it will sum each line of data until the end so put it in summary to see it sum value.

 

Second approach is using sum function in SQL command :P. I'm kidding.. Just add new variable

-set Variable Type to Number type

-In the expression type ...

new Integer(($V{TotalVal}.intValue()) + $F{item_to_sum}.intValue())

 

-In the Initial value put

new Integer(0)

-Then use this variable to make summary field :P

NOTE : I know this method is kinda complex than the first one but... IT FUN :)

 

That all i know. Hope it help

Jeng

 

 

 

 

By: Miko Yung - hly

RE: Help for using Parameters

2003-04-30 10:18

Thanks for you help for teaching me how to do the calculations. I really appreciate your help.

 

But I'm still having question about the parameters.

In the webapp which comes with IReport, it shows how to add parameter like the example you gave me.

 

Map parameters = new HashMap();

parameters.put("ReportTitle", "Just Report Name");

parameters.put("myParaeter", "This is Value");

 

But i'm trying to call the function,

byte[] bytes = null;

 

try

{

// Connection conn = new Connection(

bytes =

JasperRunManager.runReportToPdf(

reportFile.getPath(),

parameters,

new WebappDataSource()

);

}

The third parameter in the runReportToPdf requires either java.sql.Connection or JRDataSource, do I need to call the connection again because I had made a connection in the XML file.

 

thanx a lot

Jennie

 

 

 

 

By: Miko Yung - hly

RE: Help for using Parameters

2003-04-30 10:19

Thanks for you help for teaching me how to do the calculations. I really appreciate your help.

 

But I'm still having question about the parameters.

In the webapp which comes with IReport, it shows how to add parameter like the example you gave me.

 

Map parameters = new HashMap();

parameters.put("ReportTitle", "Just Report Name");

parameters.put("myParaeter", "This is Value");

 

But i'm trying to call the function,

byte[] bytes = null;

 

try

{

// Connection conn = new Connection(

bytes =

JasperRunManager.runReportToPdf(

reportFile.getPath(),

parameters,

new WebappDataSource()

);

}

The third parameter in the runReportToPdf requires either java.sql.Connection or JRDataSource, do I need to call the connection again because I had made a connection in the XML file.

 

thanx a lot

Jennie

 

 

 

 

By: Ratchapong - jeng

RE: Help for using Parameters

2003-05-01 19:20

Hi,

The connection is connection... urrrrr ..... It is the way how you get connect to your database. The format should be somethings like ...

 

String driver = "org.gjt.mm.mysql.Driver";

String connectServer = "jdbc:mysql://localhost:3306/testDB";

String user = "root";

String password = "justPassword";

Class.forName(driver);

Connection conn =

DriverManager.getConnection(connectServer, user, password);

return conn;

 

(as you can see i'm using mysql). It seems there are somethings wrong about your code. You should know the truth about jasper report how it works.. ummm

You create .XML first then compile it and get .jasper file then you use this jasper to get .jrprint which is the ready to print. You can compile it at run time but i have seen some messages on jasper's forum note about this. "don't compile it at run time" ....

 

Have more fun.

Jeng

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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