Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Crystal Reports For Eclipse - Multi-values not showing on page..

Tried two different ways to set params, but to no avail. Values seems to be set, but only one value appears on the report.The value is updated, so not an old value or anything.

Also if I look at the values I can see the values are set! The Field is set to multi=true and the height is big enough to display lots of date grow=true.

<%@page import="com.businessobjects.samples.JRCHelperSample" %>

<%@page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer" %>

<%@page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>

<%@page import="com.crystaldecisions.sdk.occa.report.application.OpenReportOptions" %>

<%@page import="com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase" %>

<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSource" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.Fields" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.ParameterField" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.ParameterFieldDiscreteValue" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.Values" %>

<%@page import="com.crystaldecisions.reports.sdk.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

<%@page import="com.crystaldecisions.sdk.occa.report.data.*" %>

<%

// This sample code calls methods from the JRCHelperSample class, which

// contains examples of how to use the BusinessObjects APIs. You are free to

// modify and distribute the source code contained in the JRCHelperSample class.

try {

String reportName = "Report1.rpt";

ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);

if (clientDoc == null) {

// Report can be opened from the relative location specified in the CRConfig.xml, or the report location

// tag can be removed to open the reports as Java resources or using an absolute path

// (absolute path not recommended for Web applications).

clientDoc = new ReportClientDocument();

// Open report

clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);

// ****** BEGIN LOGON DATASOURCE SNIPPET ****************

{

// Database username and password

String connectString = "jdbc:oracle:thin:@localhost:1521:XE";

String driverName = "oracle.jdbc.OracleDriver";

String JNDIName = "";

String userName = "darren";

String password = "darren";

// logon to database

//JRCHelperSample.logonDataSource(clientDoc, userName, password);

// Switch all tables on the main report and sub reports

JRCHelperSample.changeDataSource(clientDoc, userName, password, connectString, driverName, JNDIName);

}

// ****** END LOGON DATASOURCE SNIPPET ****************

// Store the report document in session

session.setAttribute(reportName, clientDoc);

}

// Create the CrystalReportViewer object

CrystalReportViewer viewer = new CrystalReportViewer();

// set the reportsource property of the viewer

IReportSource reportSource = clientDoc.getReportSource();

viewer.setReportSource(reportSource);

// set viewer attributes

viewer.setOwnPage(true);

viewer.setOwnForm(true);

// -


// MyParameter

String paramName = "MyParameter";

String theValue1 = "Hello";

String theValue2 = " World!";

/*

// Method 2

//We will be using the ParameterFieldController quite a bit through-out the rest of this function.

ParameterFieldController paramFieldController = clientDoc.getDataDefController().getParameterFieldController();

// MULTI-VALUE DISCRETE PARAMETERS.

Object[] multiVals = {theValue1, theValue2};

// sReportName - the report that contains the specified parameter field.

// sFieldName - the parameter field name.

// newValue - the collection of values to be stored in the parameter field.

paramFieldController.setCurrentValues("", paramName, multiVals);

*/

// Method 1

Values values = new Values();

values.add(theValue1);

values.add(theValue2);

ParameterField paramField = new ParameterField();

paramField.setName(paramName);

paramField.setAllowMultiValue(true);

paramField.setAllowCustomCurrentValues(true);

paramField.setCurrentValues(values);

Fields parameterFields = new Fields();

parameterFields.add(paramField);

viewer.setParameterFields(parameterFields);

viewer.setEnableParameterPrompt(true);

// Show parameter values to console

Fields fields = viewer.getParameterFields();

for (int i = 0; i < fields.size(); i++) {

ParameterField pf = (ParameterField)fields.get(i);

Values v = pf.getCurrentValues();

if (v.isEmpty()) {

System.out.println(pf.getName());

} else {

System.out.println("v.size(): " + v.size());

for (int j = 0; j < v.size(); j++) {

ParameterFieldDiscreteValue pfdv = (ParameterFieldDiscreteValue)v.get(j);

System.out.println(pf.getName() + " - " + pfdv.getValue());

}

}

}

// Apply the viewer preference attributes

viewer.refresh();

// Process the report

viewer.processHttpRequest(request, response, application, null);

Thanks in advance!

Not what you were looking for? View more on this topic or Ask a question