Jump to content

Default value for input paramaters


jsloubet

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 months later...

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...