Jump to content
Changes to the Jaspersoft community edition download ×

Dynamic instantiation variables (reflection)

Recommended Posts

By: Alex - elninyomelon

Dynamic instantiation variables (reflection)

2006-05-04 02:03



I want to instantiate one variable or another of report in Textfield expression depending on a parameter value. For example:


I have thre variables in my report:





I have one parameter "num_var" in my report.

If num_var=1 I want to instantiate var1

If num_var=2 I want to instantiate var2

If num_var=3 I want to instantiate var3


I want to do it without conditionals expressions (...?...:...) because report contains a lot of variables.


Is it possible?



Thanks in advance









By: Alex - elninyomelon

please help me!!!!

2006-05-09 13:35

please help me!!!!







By: Lucian Chirita - lucianc

RE: Dynamic instantiation variables (reflecti

2006-05-10 05:21

You can achieve reflection via the scriptlet object:

$P{REPORT_SCRIPTLET}.getVariableValue("var" + $P{num_var})


Note that you would need to cast the value back to the varx type as getVariableValue() returns Object.








By: Alex - elninyomelon

RE: Dynamic instantiation variables (reflection)

2006-05-10 13:39

Thanks a lot Lucian.

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