Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

jasper reports - What is the difference between variable, parameter and field in JasperReports?

I am a newbie to JasperReports, have been working on some small samples. It seems "Fields", "Parameters" and "Variables" are very commonly used to demonstrate dynamic data and looks much alike. So can I ask what's their difference specifically in JasperReports?

I guess variable is something defined within a Jasper report and can dynamically change. Parameter is something taking from external source (Java..etc), field is for entities (database schema, class entity), but I don't think my understand is all right.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Parameters are simple input to JasperReports. You have to define parameters in the JasperReport before using them. You can display the value of the variable, you can use it as part of boolean expressions and you can even pass it to subreports. This can be an input to SQL query.

Fields are simple variable definitions. You can think of these as instance variables of the datasource object thats passed in to the report or they can be key names if the datasource is a Map. If you configure JasperReport to create the dataset based on SQL, then Fields are the column names of the ResultSet. You will use Fields to display the resultset of an executed SQL query.

Variables are another kind of variables that live within Jasper Report, they are not inputs. They are used to calculate sum or average of certain Field (defined above). You can perform many other predefined calculation functions on the Fields using Variables.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...