Jump to content
Changes to the Jaspersoft community edition download ×

Use Scriptlet to initialize Parameters


2005 IR Help

Recommended Posts

By: Kuba Duda - kubad

Use Scriptlet to initialize Parameters

2004-06-24 08:37

Is there a way to use Scriptlet for Parameter initialization?

I would like to do something like this:

 

<parameter name="MaxDate" isForPrompting="false" class="java.lang.String">

<defaultValueExpression >((Scriptlet)$P{REPORT_SCRITLET}).computeDate()</defaultValueExpression>

</parameter>

 

but it seems that user parameters are initialized before REPORT_SCRIPTLET:

 

parameter_MaxDate = (JRFillParameter)parsm.get("MaxDate");

 

...

 

parameter_REPORT_SCRIPTLET = (JRFillParameter)parsm.get("REPORT_SCRIPTLET");

 

Maybe it should be initialized first so it could be used in parameters initliazation like in variables initialization?

 

 

 

 

 

 

By: Chuck Deal - cdeal

RE: Use Scriptlet to initialize Parameters

2004-06-24 12:01

Could you go the other direction? In the Scriplet's Init event, initialize your variables.

 

 

 

 

By: Kuba Duda - kubad

RE: Use Scriptlet to initialize Parameters

2004-06-25 03:38

I tried this - works with variables, but not with variables - paramtersMap.put ... seems not to work

What exactly I want to do is use scritlet to compute a parameter that will be passed to sql query.

I know the easiest way to do it is to pass parameter from outside, but I want my reports to be independent from filling code as much as possible - to use one filling code for mady different reports.

 

 

 

 

 

By: Chuck Deal - cdeal

RE: Use Scriptlet to initialize Parameters

2004-06-25 06:35

Ok, I understand a little more.

 

In my project, we have a class called JasperController. This class is separate from the parameter gathering process. In our case, we have a method called getPDF that takes an OutputStream object. It takes a Map of parameters (that were set on the JasperController via a setParameters method) and fills the report (after getting a connection from the pool).

 

This whole class is generic. We have a servlet that actually managers the parameters and which invokes the JasperController to do the work.

 

So, we basically do what you are looking to do. It just looks like you need to add a JasperReports "wrapper" class (like our JasperController) into your workflow.

 

 

 

 

 

By: Kuba Duda - kubad

RE: Use Scriptlet to initialize Parameters

2004-06-25 06:50

Seems like a good idea - thanks for your help.

Anyway, I still have a feeling that initialization process (dependiences beetween variables, parameters, scriptlet, sql query) is not intuitive.

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