Setting parameter fields

After all the parameter fields have been initialized and added to the Fields object, the Fields object can be passed to the viewer.

To set parameter fields
  1. Create a CrystalReportViewer object, passing it a reference to a report source object.
  2. CrystalReportViewer viewer = new CrystalReportViewer();

        viewer.setReportSource(reportSource);

  3. Set the parameter fields for the viewer by passing in the initialized Fields object.
  4. You can disable user prompting to automatically use the set parameter field value. This is particularly useful if the parameter field value being set is unknown to the user (such as a parameter generated by the system).

    viewer.setParameterFields(fields);

        viewer.setEnableParameterPrompt(false);

  5. When setting parameters for the first time, you don't need to call the refresh method. If your report already has parameters set, then call the viewer's refresh method to apply the new parameters.
  6.     viewer.refresh();

  7. If the page contains only the viewer, call its setOwnPage method and pass in true. This allows the viewer to automatically perform page configuration and enables the print and export buttons. If the page contains elements other than the viewer, the setOwnPage method must be called with false and you need to manually set the content-type.
  8. Note:    Setting setOwnPage to false disables exporting and printing.

    viewer.setOwnPage(true);

  9. Call the processHttpRequest method to launch the viewer in the current browser window.
  10. viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);



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