Creating and initializing parameter fields

Before parameter fields can be set in a report, the fields must first be created and initialized. Individual parameter fields are all stored in a Fields object. The Fields object is simply a collection of different fields that can be passed to the viewer.

To create parameter fields
  1. Reference the required Java classes and packages.
  2. <%@ page import="com.crystaldecisions.report.web.viewer.*" %>

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

    <%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>

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

  3. Create a Fields object to store the parameter fields in.
  4. Fields fields = new Fields();

  5. Create a ParameterField object for each field that you want to set.
  6. ParameterField pfield1 = new ParameterField();

  7. Create a Values object and a ParameterFieldDiscreteValue object for each parameter field you want to set.
  8. If a ranged value is being set, a ParameterFieldRangeValue object should be used instead of the discrete value object.

    Values vals1 = new Values();

        ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue();

Once all the required objects have been created, the values for the fields can be initialized.

To initialize parameter fields
  1. Set the name and value for each parameter field that is added.
  2. Values for parameter fields are represented by a ParameterFieldDiscreteValue or ParameterFieldRangeValue object.

    You also must set the parameter field's report name to the report name associated with the parameter. If the parameter field is for the main report, use a blank string (""). The report name is set using the setReportName method.

    pfield1.setName("Country");

        pfield1.setReportName("");

        pfieldDV1.setValue("Spain");

        pfieldDV1.setDescription("The country is Spain.");

  3. Add the parameter field values to the Values collection object.
  4. vals1.add(pfieldDV1);

  5. Set the current Values collection for each parameter field.
  6. pfield1.setCurrentValues(vals1);

  7. Add each parameter field to the Fields object.
  8. The Fields object is now ready to be used with the viewer.

    fields.add(pfield1);



Business Objects
http://www.businessobjects.com/
Support services
http://www.businessobjects.com/services/support/