I am using iReport 0.4.1 and JasperReports 0.6.3, and I'm facing the trouble trying to generate a subreport:
I set in Java code .jasper subreport path, it's correct, but putting wrong path for test, no errors happen;
In subreport, putting a field for test, again no errors happen (i.e., the subreport is not accessed...);
I tried to access subreport list by two ways: as parameter and as a main report bean field (it's not the case: in fact I have two not-related reports to print in the same page, so that's why the subreport);
In almost all tries, when didn't happen error, appears a blank where subreport's data had to be
PS.: I put the subreport in Detail band, with main report data.
Could somebody help me? - both reports code below.
PS 2: I can't change versions, it's a new report in an existent structure, with this iReport and JasperReports version.
Java report calls:
parameters.put("subreportPath", projetoPath + "<CAMINHO>\\" + "xxxzz.jasper"
.................
parameters.put("ListaComparativoSaldos", listaSubreport);
//ABAIXO: nao funcionou
//parameters.put("ListaComparativoSaldos", new JRBeanCollectionDataSource(listaSubreport));
.................
return JasperFillManager.fillReport(is, parameters, new JRBeanCollectionDataSource(data));
Related
I'm trying to generate a report with Jasper Reports 5.6.0 but I always end up getting two exceptions of the following sort:
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JEditorPane[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,caretColor=,disabledTextColor=,editable=true,margin=,selectedTextColor=,selectionColor=,kit=,typeHandlers=]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:731)
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
at javax.swing.UIDefaults.getUI(UIDefaults.java:761)
at javax.swing.UIManager.getUI(UIManager.java:1016)
at javax.swing.text.JTextComponent.updateUI(JTextComponent.java:338)
at javax.swing.text.JTextComponent.<init>(JTextComponent.java:312)
at javax.swing.JEditorPane.<init>(JEditorPane.java:196)
at javax.swing.JEditorPane.<init>(JEditorPane.java:288)
at net.sf.jasperreports.engine.util.JEditorPaneHtmlMarkupProcessor.convert(JEditorPaneHtmlMarkupProcessor.java:80)
at net.sf.jasperreports.engine.fill.JRFillTextElement.processMarkupText(JRFillTextElement.java:1018)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:546)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:488)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2067)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:788)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:298)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:152)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:963)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:892)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:114)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:668)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:649)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:971)
Despite the exceptions, the report is generated, but with two missing fields, both of which should be filled with the value of the same object property. And since I have two exceptions that are exactly the same, I suspect the exceptions are the reason these fields are missing.
I have checked the object passed to Jasper Reports and the property that fills the missing fields has a value, so I believe it's not a coding problem.
I know that it'd be easier if I put the content of the .jrxml file in here but it belongs to a client, so that will not be possible. Still, any help would be appreciated.
The application is an API running on Fuse Karaf 7.3.
I am trying to unittest a freemarker.ftl file which includes jsptaglib (from the HippoCMS).
It's not working when trying to inlcuding a jsptaglib and gives me a error message.
Freemarker code;
<#include "include/imports.ftl">
<#hst.setBundle basename="freemarker.test"/>
Hello step4
I've tested to see If the template is being mocked and it actually does;
configuration.setDirectoryForTemplateLoading(new File("../freemarker"));
final Template template = configuration.getTemplate("Helloworld.ftl");
At this rate I ran the test, and I could see the raw data from the ftl file. To be sure If i actually get data from the template.
So I tried to go a step further and map it (where it goes wrong);
Map model = new HashMap();
/* populate model */
template.process(model, new OutputStreamWriter(System.out));
This is where it goes wrong and gives this error when running the test;
And the directory for the include is;
<#ftl encoding="UTF-8">
<#assign hst=JspTaglibs["http://www.hippoecm.org/jsp/hst/core"] >
<#assign fmt=JspTaglibs["http://java.sun.com/jsp/jstl/fmt"] >
<#hst.defineObjects />
Im not sure how to fix this issue, I've tried many different attempts but with no luck.
reference;
https://theodoreyoung.wordpress.com/2011/02/19/freemarker-jsp-taglibs-outside-war/#more-227
http://techqa.info/programming/question/20100276/adding-spring-security-jsptaglib-to-a-freemarker-template---issues-with-controller-unit-tests
Some are saying that this issue was fixed in the newest release of freemarker, but dosen't seems thats is the case either.
Performing a test with BIRT I was able to create a report and render it in PDF, but unfortunatelly I'm not getting the expected result.
For my DataSource I created a Scripted DataSource and no code was needed in there (as far as I could see the documentation to achieve what I'm trying to do).
For my DataSet I create a Scripted DataSet using my Scripted DataSource as source. In there I defined the script for open like:
importPackage(Packages.org.springframework.context);
importPackage(Packages.org.springframework.web.context.support);
var sc = reportContext.getHttpServletRequest().getSession().getServletContext();
var spring = WebApplicationContextUtils.getWebApplicationContext(sc);
myPojo = spring.getBean("myDao").findById(params["pojoId"]);
And script for fetch like:
if(myPojo != null){
row["title"] = myPojo.getTitle();
myPojo = null;
return true;
}
return false;
As the population of row will be done on runtime, I wasn't able to automatically get the DataSet columns, so I created one with the following configuration: name: columnTitle (as this is the name used to populated row object in fetch code).
Afterwards I edited the layout of my report and added the column to my layout.
I was able to confirm that spring.getBean("myDao").findById(params["pojoId"]); is executed. But my rendered report is not showing the title. If I double click on my column label on report layout I can see there that expression is dataSetRow["columnTitle"] is it right? Even I'm using row in my fetch script? What am I missing here?
Well, what is conctractVersion?
It is obviously not initialized in the open event.
Should this read myPojo.contractVersion or perhaps myPojo.getContractVersion()?
Another point: Is the DS with the column "columnTitle" bound to the layout?
You should also run your report as HTML or in the previewer to check for script errors.
Unfortunately, these are silently ignored when generating the report as PDF...
The problem was the use of batik twice (two different versions), one dependency for BIRT and other for DOCX4J.
The issue is quite difficult to identify because there is no log output rendering PDF files.
Rendering HTML I could see an error message which I could investigate and find the problem.
For my case I could remove the DocX4j from maven POM.
I'm trying to generate a report using Crystal Report SDK in Java composed by a main report and a subreport.
I do want to generate the report only if there is something returns by my stored procedure and for doing that I execute the proc manually and launch the report generation only if my ResultSet != null.
But, my subreport has to be generated through Crystal.
I use the setTablesDatasource() method for my main report for using my ResultSet
For my subreport:
_ I use the setTableslocation() for getting the values and generating the report through crystal
_ I set all the parameters needed in the ParameterFieldController of my subreport.
However, I'm getting this error in my console :
Missing parameter values.---- Error code:-2147217394 Error code
name:missingParameterValueError
Even though the subreport's parameters are correctly setted.
If I generate my report with no subreport or with report and no needed parameter, the generation is just fine.
Am I setting my parameters in a wrong way ?
After trying a lot of stuff for integrating my subreport without using another ResultSet, here is the way for setting the parameters for the subreport :
You have to use the ParameterFieldController of the main report and not the one of the subreport... Logic.
ParameterFieldController paramFieldController =
rptClientDoc.getDataDefController().getParameterFieldController();
paramFieldController.setCurrentValue(subreport_name, parameter_name,
parameter_value);
And now, it works just fine !
I'm trying to launch a report that I created in iReport which contains a main report and a subreport. In iReport, the subreport launches fine and contains data, however when I try to launch it from within my java code, the subreport is blank.
What I've done so far:
I have a String parameter in the main report called "SUBREPORT" that is used to define the path to the subreport. E.g. value: "E:\java\ReportLauncher\reports\test_subreport1.jasper"
The subreport expression in the main report is set to: $P{SUBREPORT}
The subreport connection expression is: $P{REPORT_CONNECTION}
I also have a subreport parameter defined called "INVOICE_NUMBER" that is set to $F{InviInvNo}, which maps to a field in the main report.
In my java code, I have:
HashMap<String, Object> paramHash = new HashMap();
paramHash.put("INVOICE_NUMBER", invoiceID);
paramHash.put("REPORT_CONNECTION", this.conn);
paramHash.put("SUBREPORT", subReportPath);
JasperPrint jasperprint = JasperFillManager.fillReport(this.reportPath, paramHash, this.conn);
The main report is created fine and is populated. The subreport area however is blank. Any thoughts for what I'm doing wrong?
Thanks in advance,
Andy.
Since you didn't mention anything about the subreport query:
If you are using the Detail Band in the subreport, then you will need a Data Query for the report.
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