Tuesday, April 14, 2009

Multi-Select Parameters - Part 2

 In a previous post I described how you could create a simple method to use multi-select parameters with a SQL IN clause in a generic fashion.  In that post I referenced that the right way to do this is to use Java Bind variables

There is a way that this can be done using Java Bind variables, but it is significantly more difficult.
But I did not explain how that is done.  Today I gave a webinar on how you can use the Design Engine API and the BIRT Script Function extension point to dynamically add parameter binding to your report designs.

The DEAPI code is a bit tricky to use, but thanks to the ScriptFunction extension, any one can use the function quickly and easily.

All of the code and the slides for the project are available on the Innovent Subversion server here.  You can use the subclipse plugin to download this code as an Eclipse project.

The slides for the presentation are included here:

BIRT Multi Select Parameters

5 comments:

joel sherriff said...

Scott, based on your work here, I wrote some javascript to do similiar. I posted it on BirtExchange (http://www.birt-exchange.org/devshare/designing-birt-reports/832-dynamic-binding-of-in-list-parameters/#description). Thanks, I'd been trying to figure out how to do it and your code showed me how.

Anonymous said...

Hi Scott,
I'm trying your plugin with birt 2.3.2 but it doesn't seem to add the dataSet parameters. The query is modified correctly, the AddParameterBinding.addParameterBinding(...) method is executed correctly but when trying to preview it always gives the error that the IN or OUT parameters are missing...
I think the parameters cannot be added beforeOpen data-set.

Anonymous said...

Anon,

I am confident (100%) that you can add parameters in the BeforeOpen method. In fact, it is the only time you can make that modification.

If you could post your report, I will have a look. I am at scottr (at) innoventsolutions (dot) com.

Anonymous said...

Jason was kind enough to point out to me that I was wrong in my last statement.

Technically, he was correct.

You can't actually add parameters in the beforeFactory method since the point where parameters are evaluated has all ready passed.

The problem is that in the example I am not actually adding parameters. Instead, what I am adding is a parameter binding in the DataSet, with a default value set. This you can do in the beforeFactory method.

Basically, we are creating a parameter binding with a hard-coded value. Now, you may say "why go to the trouble, you can just hard code into the SQL".

The difference is that when you hard code into the SQL the text is not evaluated for parameters. When you use a hard-coded parameter binding, then the hard-coded value is evaluated through the jdbc BindParameter routines.

It is the use of these jdbc BindParameter routines which protect you against SQL injection attacks.

---> tham 007 <---- said...

hi guys, i have to make a report with flash objects that uses flash maps in my local machine. Please guide me

my id => sn.gowtham@gmail.com