Programming using the BIRT Reporting APIs : Generating reports from an application : Accessing a report parameter : How to use cascading parameters
 
How to use cascading parameters
The code sample in Listing 12‑8 accesses the set of valid values for each parameter in the cascading parameter group in turn. The variable, task, is an object of type IGetParameterDefinitionTask.
Listing 12‑8 Getting the valid values for cascading parameters
// Create a grouped collection of the design’s parameters.
Collection params = task.getParameterDefns( true );
 
// Iterate through the parameters to find the cascading group.
Iterator iter = params.iterator( );
while ( iter.hasNext( ) ) {
IParameterDefnBase param = (IParameterDefnBase) iter.next();
if ( param.getParameterType() == IParameterDefnBase.CASCADING_PARAMETER_GROUP ) {
ICascadingParameterGroup group = (ICascadingParameterGroup) param;
String groupName = group.getName();
Iterator i2 = group.getContents( ).iterator( );
 
Object[ ] userValues = new Object[group.getContents( ).size( )];
 
// Get the report parameters in the cascading group.
int i = 0;
while ( i2.hasNext( ) ) {tOptio
IScalarParameterDefn member = (IScalarParameterDefn) i2.next( );
 
// Get the values for the parameter.
Object[ ] setValues = new Object[i];
if ( i > 0 ) {
System.arraycopy( userValues, 0, setValues, 0, i );
}
Collection c = task.getSelectionListForCascadingGroup( group.getName(), setValues );
String[ ] choiceValue = new String[c.size( )];
String[ ] choiceLabel = new String[c.size( )];
 
// Iterate through the values for the parameter.
Iterator i3 = c.iterator();
for ( int j = 0; j < c.size( ); j++ ) {
IParameterSelectionChoice s = ( IParameterSelectionChoice ) i3.next( );
choiceValue[j] = ( String ) s.getValue( );
choiceLabel[j] = s.getLabel( );
}
// Get the value for the parameter from the list of
// choices. This example does not provide the code for
// this task.
userValues[i] = inputChoiceValue;
i++;
}
}