iReport: localized default values for parameters - jasper-reports

How to use localized default values for parameters in iReport?
Using a $R{message.key} as the parameter default value has negative consequences in the "Read fields" functionality of iReport's SQL editor. More precisely, the following error is shown (after pressing the Read fields button in Report query dialog):
Sourced file: inline evaluation of: ``$R{message.key}'' : Attempt to access property on undefined variable or class name
Any way around this iReport problem?
Here is the image to illustrate the problem:

I think this is a iReport's bug.
You can temporary comment the defaultValueExpression expression and add the fields via the Report query -> Read fields button.
Or you can manually add the fields declaration.

This is iReport bug ! To solve this issue please follow the below steps.
Open XML File
Remove defaultValueExpression tag value.

Related

Display Jasper report file name

I'm creating a jasper report using iReports 5.2.0 and I want to display the report file name in it.
Can't find any variable that has that information and I would like to get an alternative to pass it in the parameters.
How can I do it?
When you design your report, make a new PARAMETER named, for instance: NAME_REPORT.
After that, put a TextField in your report, for example, in your Title section, and
put as value of your TextField the parameter like a expression: $P{NAME_REPORT}
When you preview your report, ask you to give a value to this parameter and then, you see the title with the name
of your report file.
In your java code you will do somethink like that:
parameters.put("NAME_REPORT", "myreport.jrxml");
.....
JasperFillManager.fillReport(report, parameters, connection)
.....

Field not found, JRXML has definitions?

I'm using iReport Designer 5.5.0, and was making a test JRXML. I added a text field with a value of $F{pricing_date} and added "pricing_date" to the list of "fields" on the Report Inspector panel (no properties or description set for the field).
The resulting JRXML has the "pricing_date" field defined:
<field name="pricing_date" class="java.lang.String"/>
And it has a text field with $F{pricing_date} as expected:
<textFieldExpression><![CDATA[$F{pricing_date}]]></textFieldExpression>
But... I get the error "Field not found : pricing_date" within iReport, and I get the same error during compilation.
I've compared this to other JRXML files within the samples provided, and it seems to match... what am I missing? Is there a setting somewhere to recognize field definitions?
I can see two possible reasons here.
If the report does not compile, the problem might be that the element in which you have placed the textField uses a different datasource than the one in which you have declared the field.
If it does not run, you might be missing the field in the object type of the datasource. Also, if you use JRBeanCollectionDataSource from java you have to have the getter for your field (declared as getPricing_date(){...}).
Hope this helps.

JasperReport parameters works in iReport but fails on JasperServer with input control

JasperServer doesn't pass parameter from input control to the report for some unknown reason.
I defined a jrxml report with iReport 4.6 (even tried compatibility mode 4.0.1) using input parameter which works in iReport.
When I deploy the report on jasperserver 4.5 the response I get is "The report is empty".
Same report without parameter works also well.
Naturally I defined and attached input control with single-select query.
The value column and the visible column in input control is the same DB field I use as parameter in jrxml.
Query values as possible input are displayed fine, but when I choose one..."The report is empty"!!.
I tried simplifying the report but my parameter from input control just wont be passed through to render the report.
You must create the parameter in jasperserver too (not only in iReport), with same name.
In JasperServer, edit your report, define "Input controls" with same ids and go thru wizard, it should work now.
If you like to test first select "Always require in emergin window".
You can also look at the answer here http://jasperforge.org/node/543148

How to add a non editable field using install4j - value of this is not static and should be displayed from a user defined variable

I would like to be able to add a key/value pair label in an install screen. The key is a static text. The value is a dynamic value and a value from a variable should be used to display the value label. I'm not able to do so using install4J. I see options like a textArea, textfield that will enable to be able to do so. However, these are editable fields and does not serve my purpose. I want a non editable field to display a value from a variable. This is not a system variable. This should be a user defined variable. I'm using install4j 4.2 version. Any help in this area is highly appreciated.
Thanks for the response. I was able to create key/value pair. However, I'm not able to define my own installer variable. Can you please let me know where I can define an installer variable that can be used in the key/value pair?
There is a "Key value pair" form component that does exactly what you need. It is available in install4j 4.2.
In the "Value label/Text" property, you can use an installer variable like
${installer:myValue}
for displaying dynamic text.

"Document has no pages" on iReport and nothing on OpenReports

I am having an issue with JasperReports I can not solve. I am using Eclipse, OpenReports 3.2 and IReport 3.7
The issue I am having is that the report does nothing. When I preview the report in IReport I can at least get a "Document has no pages" message but when I try to open it using OpenReports it doesn't do anything. I get the open reports header and the copyright message but nothing between them.
I was able to track it down to line 150 in ReportRunAction.java in OpenReports. That line is:
jasperPrint = jasperEngine.fillReport(reportInput);
At least that is the line the page dies on. It trips the catch block that the line is inside of but the error is empty. When I try to print the description it is null. I can't swear that the issue isn't that parameter. Through looking around all I have been able to find is something about how the report needs to be compiled with the same version of the jasperreports.jar that OpenReports uses. I have no idea how to tell if/what version of jasper reports is being bundled into the .jasper file though.
Is that my problem? If so how do I tell/set the version of the jar that gets bundled? If not; help!
The no pages messages comes out when the report has not records or you discarded all of them with a wrong filter expression.
There are a couple of things you can try:
set the filter expression to:
new Boolean (true)
This will in some way reset your filter expression.
Right click your jasper report
properties
find more...
and Set the report property "When no data" to "All sections no details" so you can see at least the rest of the report.
Thanks.
If you are using the Detail Bandeport, then you will need a Data Query for the report. Since it's returning "No Pages" in iReport, then you either don't have a query. Or simply your query is not returning any rows.
In old iReport, from Data menu, choose Report Query and write your query here. If you want only one record (i.e. Detail band only one time) you can use a dummy table. Like:
SELECT 'a' FROM DUMMY
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit menu, choose Report Properties, under More... tab, set the flag When no data to All Sections, no detail
Your problem is not exceptions or errors, it's just no data to show.
Any Empty Datasource will do the trick too.
I ran into the same error when using IReports when I had a subreport that only contained other subreports and no actual query. Adding a dummy query as medopal suggests fixes the no pages error and allows things to run correctly.
See also: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=49315
I've been facing this error for a while. In my case, this error occurred because of an image. If you have images in your report file, you will be forced to fill image with valid data when you wanna use report. If you don't, you will see this error "Document has no page". To address this problem just set "on error type" field in properties window (just click on image you'll see the property window) to "blank".
Strong wish.
I had same problem and got after searching problem, that I did not provide password to connection.
so I add these lines to my java code.
Class.forName("com.mysql.jdbc.Driver");
con =DriverManager.getConnection("jdbc:mysql://localhost:3306/stock_mngt","root","your password");
now my code works.