Default value for input paramaters

Hi,

 

I'm trying to create a jasperserver report in uploading a jrxml generated by iReport.

I have to add input control to my report but I don't find the way for defining a default value.

I need it because my ireport report has an image whose path is given by a parameter.

 

Is it possible ? (i'm using the 3.5 pro version)

Thank you in advance,

Julien

jsloubet's picture
265
Joined: May 25 2009 - 8:46am
Last seen: 13 years 10 months ago

10 Answers:

I define a default value in iReport when I create Parameters for example: Parameter DATE_END : DataType - Date Default Value Expression - new Date()
natalya's picture
83
Joined: May 4 2009 - 8:59am
Last seen: 2 years 9 months ago

Hi Julien

You can define the default value for a parameter by inserting a <defaultValueExpression> element withing the <parameter> element in your jrxml file

 

e.g.

<parameter name="MyDate" class="java.util.Date">

    <defaultValueExpression>

        new java.util.Date()

    </defaultValueExpression>

</parameter>

 

hope this helps

Angus

 

angus's picture
72
Joined: Apr 3 2007 - 4:09am
Last seen: 15 years 11 months ago

Hi,

 

Thanks for your response.

Is it not possible to linked the image to the report if this image is defined as a jasperserver ressource ?

If not, indeed, I will indeed edit the jrxml to put the image path, hard coded.

Julien

 

jsloubet's picture
265
Joined: May 25 2009 - 8:46am
Last seen: 13 years 10 months ago

jsloubet
Wrote:

Is it not possible to linked the image to the report if this image is defined as a jasperserver ressource ?

I don't understand what you are trying to do.  Could you ellaborate?

Regards,

Lucian

lucianc's picture
72485
Joined: Jul 17 2006 - 1:10am
Last seen: 9 hours 32 min ago

Hi,

 

My "ireport report" got an image. The image path is given by parameter to the report.

This report was launch by a java prog which sent parameters. The parameter for the image was a string and was declared as a string in iReport.

Now I want use this report with jasperServer. The image path could change, so I need to conserve it as a parameter. I can't let the parameter as a string because it seems impossible to define default values to the parameters declared with jasperserver (I don't want my users have to enter a path for the image, I should be transparent for them).

So I tried to define my image as a ressource and use it as a parameter of my report. But I don't know how to make iReport (I modify the report with iReport) recognise it.

I'm not sure I'm clear, let me know if so.

Thanks,

Julien

jsloubet's picture
265
Joined: May 25 2009 - 8:46am
Last seen: 13 years 10 months ago

jsloubet
Wrote:

I'm not sure I'm clear, let me know if so.

Not very (but maybe it's just me).  I still don't understand where the image path comes from, and what you need a parameter for.

You can have default values for input controls, define a default parameter expression in the report (as Angus said).

If you have the image as a JasperServer resource, you should use "repo:" URLs as image source expression.  See the sample reports shipped with JS for examples.

Regards,

Lucian

lucianc's picture
72485
Joined: Jul 17 2006 - 1:10am
Last seen: 9 hours 32 min ago

I have a similar issue with image mapping. I am building a reporting service for an internet mapping application. I need to include an image and a thumbnail of the map area and the crosshair based on parameters sent from the map service. I have tried to add an image to the report and then create an expression something like this . The paramter will be input as a url parameter like this http://155.187.1.78:8080/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/reports/samples/ert&standAlone=true&j_username=jasperadmin&j_password=jasperadmin&ParentFolderUri=/reports/samples&output=html&image_path=C:\\\\WINDOWS\\\\Web\\\\tips.gif.

I don't understand why the hard coded image expression that looks exactly the same as the parameter will work in ireport, and in the above url, but when passed as a parameter, it give the following error: Errorloadingbytedata:$P!{image_path} . Surely there is a simple answer.

mc53's picture
268
Joined: Jul 14 2009 - 10:21pm
Last seen: 13 years 8 months ago

mc53
Wrote:

I don't understand why the hard coded image expression that looks exactly the same as the parameter will work in ireport, and in the above url, but when passed as a parameter, it give the following error: Error loading byte data : $P!{image_path} . Surely there is a simple answer.

Did you use $P!{image_path} as image expression? If so, change it to $P{image_path}, only queries can do $P!{..}.

HTH,

Lucian

lucianc's picture
72485
Joined: Jul 17 2006 - 1:10am
Last seen: 9 hours 32 min ago

Hi, and thankyou for your fast reply Lucian.

I have tried $P!{..} and still get "com.jaspersoft.jasperserver.api.JSExceptionWrapper: Byte data not found at location : ((java.lang.String)parameter_image_path.getValue())". I have used paths with escaped \\ and without escapes, and they both give the same errror. Leads me to believe that JS is expecting a certain syntax for image paths. I really need to do it this way becase the image is created by a service and then destroyed after use. It is accessible by the report service only by a path whic the service provides to the report.

mc53's picture
268
Joined: Jul 14 2009 - 10:21pm
Last seen: 13 years 8 months ago
I have found that the $P{} in the expression must not have quotes around it. That is why the literal parameter_image_path.getValue() is returned instead of the actual value. Thankyou Margot
mc53's picture
268
Joined: Jul 14 2009 - 10:21pm
Last seen: 13 years 8 months ago
Feedback
randomness