Jump to content
Changes to the Jaspersoft community edition download ×

Default value for a collection that is from a query


mwarner_2

Recommended Posts

I know how to create default values for a collection parameter that is used in a list of values input control.  Works fine.

But I can not get that to work when the input control is from a query (a stored procedure in this case).  Any clues?

My parameter is a collection.  I have tried, unsuccessfully, using the following for the Default Value Expression:
new ArrayList(Arrays.asList("value1","value2","value3))
new ArrayList(Arrays.asList(new String [] {"value1","value2","value3}))

In JS Studio, the default values show up.  But not in JS Server.

I have to believe it seems from the input control being a query.

Any suggestions?

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I also had to figure this out. So my default values for multiselect inputs look something like this: '(java.util.Collection)(Arrays.asList(1,2,3))' with java.util.Collection as the class and java.lang.Integer as the nested type. Those represent the pk for the field we're comparing to. Then when setting up the input in Jasper Server I'll add label and value so it shows the description but compares the ids. Hopefully this answers your question... If you question was how to use a query to set the default value of an input then I can't help because that is what I'm trying to figure out now

Link to comment
Share on other sites

srang - Appreciate your effort.  But it didn't work for me.

For this parameter, these are the values I tried:
Class: java.util.Collection
Nested Type Name: java.lang.String
Default Value Expression - (java.util.Collection)(Arrays.asList("abc","mno","xyz"))  (well not exactly those values)

But after publishing to JS Server, running the report, those values are not pre-selected.
 

Does it matter that not all the default values are in the values returned by the input control's underying query?

Link to comment
Share on other sites

After more experimenting, I have discovered more about this "problem".  Let's call this parameter (for which I want to have default values) Employee_Types.

The query populating the collection values for Employee_Types is dependent on another parameter value being entered by the user.  Say this other parameter is Customer_Number.

When I enter a default value for the Company_Number (in JS Studio), publish and then run the report, then there are pre-selected choices for Employee_Types.
But If I change the Company_Number, then click off of that field, none of the the Employee_Types are pre-selected.

So when a new Company_Number is entered, then the default values are no longer considered (even though the query for Employee_Types is being run again).

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