Jump to content
Changes to the Jaspersoft community edition download ×

Pass Collection as Link paramerter (Multi-Select)


yashdeep

Recommended Posts

Hello!

I have a bar chart report with a multi-select input control (say on Country), it works fine. Problems comes when i am opening a report by passing values of multi-select input control to another report using link parameter and that report also contains a multi-select input control on it (on same Country ), here i want to show all those countries selected, those i already selected on main report.

In other word i want to set default values for Multi-Selection input control on Child report with the values i selected in main report.(Both reports main and child has a multi-selection input control on Country)

I used following syntax to set default value to County Multi-Select input control (of type java.util.Collection) on main report

java.util.Arrays.asList(new string[] {"INDIA","USA"}) its working fine. Now how to do it for child report while calling child report from main report using link parameters

If any one knows how to do it, pls let me know ASAP. It’s urgent.....

Thanks & Regards,

Yash

Link to comment
Share on other sites

  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 weeks later...

No extra classes are required, here is the trick:

1. Define 3 parameters, in this specific order, let's say:
linkParameter (String)
inpunControlParameter (Collection)
realParameter (Collection)

The realParameter is the one you'll use in the report, in the query etc.

Set as default value expression for realParameter this expression:

($P{linkParameter} != null && $P{linkParameter}.length() > 0) ?
   java.util.Arrays.asList( $P{linkParameter}.split(",") ) : $P{inpunControlParameter}


2. Create an input control for the parameter inpunControlParameter (i.e. a multi-select from a query)
3. Create an input control for the parameter linkParameter of datatype text, and make it not visible (if you are in JS 3.5.0)

The idea is that the realParameter tries to create a collection from a string if linkParameter has a value, otherwise will
get the value from inpunControlParameter.

In the hyperlink you need to set a value for linkParameter, it must be a string with the elements separated by a comma (you can use another character) like:

item1,item2,item3


Hope it is clear.

Giulio

Link to comment
Share on other sites

Hi Guilio,

                 I am able to get the value but when see the result it only shows the result of the first value.

                Let me explain this a bit more:

               Suppose i am sending String "Gent Footwear,Ladies Footwear,Kids Footwear" as link parameter

                then the child report would only run for the Gents Footwear  and thats it ,becoz of Split method split the String by    

                comma 

              I think i am clear to you.

Vishal.

 

Link to comment
Share on other sites

Hi Guilio,

                 I have created the hyperlinks on chart data.also linkParameter i created are of text type and not visible and inputControlParameter are of multiselect query type.

                I think if i am getting only one value at second report so there should be a Scriplet at child report which will convert the String into Object [].

                Plz Suggest me how to do this.

Vishal

 

 

Link to comment
Share on other sites

Hi Guilio,

           I am able to get the values of linkParameter and convert it into collection but i need to show the selected value of Main 
report to Child Report .

           I am using Scriptlet method which is returning collection in Default Value Exprression of inputControlParameter but not getting the desired result.

Vishal

Link to comment
Share on other sites

Hello Giulio,

                  I am passing multiselect values from Main report to Child Report as link parameter by doing some Scriptlet , tricks. I am getting the desired result .

                 But I need to show the selected values of Main report remain selected to Child Report  as well in Jasper .

                Any Suggestions Plz.

Vishal

Link to comment
Share on other sites

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