Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 244880

Summary: Can't specify multiple values for a parameter in viewer tag library
Product: z_Archived Reporter: John MG <muirhejs>
Component: BIRTAssignee: Vincent Petry <vpetry>
Status: VERIFIED FIXED QA Contact: Xiaodan Wang <xwang>
Severity: enhancement    
Priority: P3 CC: bluesoldier, pvolchek, skandyinwonderland, vpetry, zqian
Version: unspecifiedKeywords: plan
Target Milestone: 2.3.2   
Hardware: All   
OS: Windows XP   
Whiteboard: Non-Auto

Description John MG CLA 2008-08-21 16:38:09 EDT
I have a parameter that accepts multiple values via listbox; i would like to be able to provide the data to the report viewer from the tag library:

One could probably specify the "value" for the birt:param a few different ways, but I have not yet found a way that works:

Ex:

<birt:report id="birtViewer" reportDesign="report/param_4.rptdesign"
height="600"
width="800"
format="html"
reportContainer="div"
isHostPage="false"
>
<birt:param name="customerNames" value="Cust1"></birt:param>
<birt:param name="customerNames" value="Cust2></birt:param>
</birt:report>
</body>
</html>

OR:

<birt:param name="customerNames" value="{'Cust1','Cust2'}"></birt:param>
Comment 1 Vincent Petry CLA 2008-08-21 22:21:42 EDT
You can try passing a Java array directly this way:

   <birt:param name="customerNames" value="<%= new String[] {"value1","value2"} %>" />

You can use this as a workaround.

Since it is not very clean to require the user to use JSP scriptlets, we will add a new value tag that will allow to specify multiple values this way:
   <birt:param name="customerNames">
      <birt:value>value1</birt:value>
      <birt:value>value2</birt:value>
      <birt:value>value3</birt:value>
   </birt:param>
Comment 2 John MG CLA 2008-08-27 08:41:20 EDT
This works great!! Thanks!
Comment 3 pvolchek CLA 2008-09-12 17:51:13 EDT
I am generating the report using the command line and passing the parameter file as an option:

When I pass a single value to a parameter, my parameter file looks like that:

my.param
value=45

How do I modify the value, so that I could pass an array there?
It would be nice if Birt could automatically convert passed values to an array, when the parameter has an array type.
For example, if both value1 and value2 are parameters that accept multiple values, then when Birt encounters the foolowing values it would threat them as an array, even though the first value is a single parameter only

my.param
value1=45
value2=45,56,78
Comment 4 Vincent Petry CLA 2008-11-30 22:07:16 EST
(In reply to comment #3)
> I am generating the report using the command line and passing the parameter
> file as an option:
> 
> When I pass a single value to a parameter, my parameter file looks like that:
> 
> my.param
> value=45
> 
> How do I modify the value, so that I could pass an array there?
> It would be nice if Birt could automatically convert passed values to an array,
> when the parameter has an array type.
> For example, if both value1 and value2 are parameters that accept multiple
> values, then when Birt encounters the foolowing values it would threat them as
> an array, even though the first value is a single parameter only
> 
> my.param
> value1=45
> value2=45,56,78
> 

Your issue is not related to taglib, please file a separate bug using the "Engine" component.
Comment 5 Vincent Petry CLA 2008-12-11 01:48:59 EST
It's now possible to specify multiple values, in different ways:
1) <birt:param name="customerNames" value="Cust1,Cust2" delim="," /> where the delim attribute specifies the delimiter (defaults to pipe "|")
2) <birt:param name="customerNames">
      <birt:value value="Cust1" />
      <birt:value value="Cust2" />
   </birt:param>
3) <birt:param name="customerNames">
      <birt:value>Cust1</birt:value>
      <birt:value>Cust2</birt:value>
   </birt:param>
4) The scriptlet way still works:
   <birt:param name="customerNames" value="<%= new String[] {"Cust1","Cust2"}
%>" />
Comment 6 Xiaodan Wang CLA 2008-12-18 04:24:36 EST
Verified in build (2.3.2.v20081218-0730) and build (2.5.0.v20081218-0630).
Comment 7 Skandy CLA 2009-04-15 09:20:47 EDT
Hi,

i'm using the code below to set values for a multiple values parameter "testMultiValuesParam"

If i create the parameter "testMultiValuesParam" in my report as a Listbox and allow multiple values params["testMultiValuesParam"].value is always null ! (I've tried static and dynamic values from dataset when defining the report parameter)

I've tried with the same code defining the parameter as a textbox (single value), params["testMultiValuesParam"].value returns the first value defined in the tag lib ( it returns Cust1 )

<birt:viewer id="birtViewer" pattern="run" showToolBar="false" showNavigationBar="false" showTitle="false" reportDesign="test.rptdesign"
height="768"
width="1024"
format="html"
>

<birtaram name="testMultiValuesParam">
<birt:value>Cust1</birt:value>
<birt:value>Cust2</birt:value>
</birtaram>

</birt:viewer>

BIRT 2.3.2.r232_20090202 Build <2.3.2.v20090218-0730> (both designer and engine)

Thank you for helping.
Comment 8 Skandy CLA 2009-04-15 10:14:32 EDT
BUG reported here : https://bugs.eclipse.org/bugs/show_bug.cgi?id=272306

(In reply to comment #7)
> Hi,
> 
> i'm using the code below to set values for a multiple values parameter
> "testMultiValuesParam"
> 
> If i create the parameter "testMultiValuesParam" in my report as a Listbox and
> allow multiple values params["testMultiValuesParam"].value is always null !
> (I've tried static and dynamic values from dataset when defining the report
> parameter)
> 
> I've tried with the same code defining the parameter as a textbox (single
> value), params["testMultiValuesParam"].value returns the first value defined in
> the tag lib ( it returns Cust1 )
> 
> <birt:viewer id="birtViewer" pattern="run" showToolBar="false"
> showNavigationBar="false" showTitle="false" reportDesign="test.rptdesign"
> height="768"
> width="1024"
> format="html"
> >
> 
> <birtaram name="testMultiValuesParam">
> <birt:value>Cust1</birt:value>
> <birt:value>Cust2</birt:value>
> </birtaram>
> 
> </birt:viewer>
> 
> BIRT 2.3.2.r232_20090202 Build <2.3.2.v20090218-0730> (both designer and
> engine)
> 
> Thank you for helping.
>