|
|
Re: Given a parameter name, how can I find to which group it belongs? [message #832948 is a reply to message #832589] |
Fri, 30 March 2012 19:28 |
|
If you have the parameter handle you should be able to do this:
if ( parameterHandle.getContainer( ) instanceof
CascadingParameterGroupHandle ){
String groupName = parameterHandle.getContainer( ).getName( );
Jason
On 3/30/2012 6:14 AM, Alexey Romanov wrote:
> This is a working approach (which hopefully can be simplified):
> IReportRunnable report = context.getReportRunnable();
> IReportEngine engine = report.getReportEngine();
> IGetParameterDefinitionTask task = engine
> .createGetParameterDefinitionTask(report);
> Collection<IParameterSelectionChoice> selectionList = null;
> Collection<IParameterDefnBase> paramsAndGroups = task
> .getParameterDefns(true);
> for (IParameterDefnBase paramOrGroup : paramsAndGroups) {
> if (paramOrGroup instanceof CascadingParameterGroupDefn) {
> List<IParameterDefnBase> members = ((CascadingParameterGroupDefn)
> paramOrGroup)
> .getContents();
> int groupSize = members.size();
> int indexInGroup;
> for (indexInGroup = 0; indexInGroup < groupSize
> && !parameterName.equals(members.get(indexInGroup)
> .getName()); indexInGroup++) {
> }
> if (indexInGroup < groupSize) {
> // found!
> Object[] prevChoices = new Object[indexInGroup];
> for (int i = 0; i < indexInGroup; i++) {
> prevChoices[i] = context.getParameterValue(members
> .get(i).getName());
> }
> selectionList = task.getSelectionListForCascadingGroup(
> paramOrGroup.getName(), prevChoices);
> break;
> }
> }
> }
> if (selectionList == null) {
> // parameter isn't in a cascading group
> selectionList = task.getSelectionList(parameterName);
> }
> Object parameterValue = context.getParameterValue(parameterName);
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02338 seconds