DataSourceConfigPanel Add Report Parameters/Evaluate Them

I’m trying to create a DataSourceConfigPanel whose inputs can be report parameters. How does one add the magnifying glass button available on the AlarmJournal ReportDataSource?

Once a report parameter input is had, where/how should it be evaluated? Is it in the ReportExecutionData? Or maybe you must call ReportExecutionContext.executeExpression()? Is it wise to resolve this in ReportDataSource.gatherData() or before hand?

Here’s an example of the code that adds the magnifying glass to the start date field in the AlarmJournal data source panel: JideToolbarButton startDateKeyButton = new JideToolbarButton( IconUtil.getRootIcon("inspector/search-small.png"), i18n("reporting.Inspector.KepMapEditor.PickKey")); new ParameterKeyPopup(reportResource, startDateKeyButton) { @Override protected void onKeySelected(String key) { startDate.setText("{" + key + "}"); } }; panel.add(startDateKeyButton);

To evaluate that start date field in the query source, we call Date startDate = (Date) parseExp(queryConfig.getStartDate(), parseContext, execContext); That function is something along the lines of @Nullable private Object parseExp(String exprStr, AbstractMultiLevelExpressionParseContext parseContext, ReportExecutionContext execContext) { Object parsedObj = null; try { Expression expr = StringParser.newQueryParser().parse(exprStr, parseContext); Object[] children = expr.getChildren(); if (children != null && children.length > 0) { if (children.length == 1) { ConstantExpression child = (ConstantExpression) children[0]; parsedObj = child.getValue(); } else { StringBuilder sb = new StringBuilder(); for (Object child : children) { sb.append(((ConstantExpression) child).getValue()); } parsedObj = sb.toString(); } } } catch (Exception e) { execContext.getLog().debugf("Error in parsing expression %s", exprStr, e); } return parsedObj; }

I was hoping the example we had posted in the SDK would have demonstrated this, but I see it didn’t. :/

As a note to anyone else trying to do a similar thing, reportResource isn’t a field of the restJsonDataConfigPanel in the example project. You will need to add it to your config panel class and pass reportResource to your ConfigPanel’s constructor in the createConfigPanel() function of your DataSourceConfigFactory.

Thanks, Kathy.