cancel
Showing results for 
Search instead for 
Did you mean: 

JSP/WebViewer - set parameter values to display in Parameter dialog as suggest

Former Member
0 Kudos

Hello, Community,

i'm struggling with the parameter dialog in the CrystalReportViewer.

I hope, i'm posting this question in the right place...

I'm developing a JSP application to display Reports. Parameter values are read from a database, when the report is opened, set to the viewer and saved to the database, when the user changes them in the viewer. This works fine.

But as soon as i set the parameter values programmatically to the viewer, the Parameter dialog is not showing up any more, and the report is opened immediately with these parameters. Instead, i would need to set the parameter values as suggest values, so the user can see and change them in the dialog.

I tried several approaches to set the values in a way to get this behavior with no success (it's more like guessing and not knowing, what i do).

Is it maybe possible to get the values from the database and save them in the report document somehow?

Any help would be appreciated! Thanks.

Here is the code  where i set the parameter values to the fields:

List<ParameterInfo> results = queryBean.getReportParameters(reportName);

    if (results == null || results.isEmpty()){

        return;

    }

  

   String parameterName = "";

   ParameterField paramField  = null;

   Values newValues = null;

 

   // now map the parameter values to the parameter

   for (ParameterInfo parameterBean : results){

       

      // yet another value for the same parameter?

      if (!parameterBean.getParameterName().equals(parameterName)){

          newValues = new Values();

          parameterName = parameterBean.getParameterName();

        

          // get the next parameter field

         paramField = getParameterField(parameterName, paramFields);

         if (paramField != null){

            paramField.setCurrentValues(newValues);

         }

      }

      // set the parameter value from parameterBean to the value list

      if (paramField != null){

         addParameterValue(paramField.getType().value(), parameterBean, newValues);

      }

   }

 

   // set the fields with the new values to the viewer

   crViewer.setParameterFields(paramFields);

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

What you will probably have to do is create you're own dialog to allow the user to set the parameters.  The only other way to set the default values for the parameters might be to run the report with your desired default values before saving it.  The problem with this technique is that there is no way to dynamically set default date values based on the current date - but it might work for all other types of parameters.

-Dell

Former Member
0 Kudos

Dell,

thank you very much for your response - that's what i was suspecting. I will probably go for doing my own dialog - we tried to avoid that because of the time this will take, but - that's life

Regards, Claudia

Answers (0)