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 !
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.
Can someone post a working example of how to define a subreport using web service as the datasource?
I am reading this:
http://community.jaspersoft.com/project/web-service-data-source
Under the section "SubReport and Additional Datasets", I need to cater the scenario for (2):
you have a main resultset that you wish to loop, and for each row you want to execute a new query (webservice call)
In the subreport configuration (or the dataset) specify not to use any connection at all (leave blank both the connection expression and the datasource expression. The only thing we'll have to do is passing some mandatory parameters for internal webservice datasource to work properly:
uriKeyauth
TypeKey
authParametersKey
languageKey
verbKey
I am not able to understand what to do here based on the above statements. These parameters are defined in the web service subreport. Am I supposed to pass them back to the main report? If so how am I supposed to do it in Jaspersoft Studio? I am using version 6.2. Even after I define these parameters in the main report, when I run preview, I get the error:
Caused by: net.sf.jasperreports.engine.JRException: Verb should be POST or GET . is not a valid verb
After struggling with this for quite a while, I found the following.
In my case, the default data adapter in the main report is JDBC. For each row returns from the SQL query, one particular column value is used as a GET parameter for the web service data adapter or WebServiceQuery.
I cannot make this work with subreport. However, I can get this to work with a dataset associated with a table.
A dataset using the web service data adapter has to be created. Parameters that are required for the GET parameters need to be defined in the dataset.
After the dataset is created, create a table or other elements using this dataset. Under the dataset tab in the table properties, define the parameters which should have the relevant field values (eg, $F{field1}).
The web service dataset also needs to connect to the main dataset. All this does is define the web service parameters: uriKey, authTypeKey, authParametersKey, languageKey, verbKey in the main report.
Once this is done, previewing the main report will also render the table with results obtained from the web service data adapter.
The steps to I use in Jasper Studio 6.3 are:
Create web service data adapter that your subreport will use.
Using the context menu, export the data adapter to a file in your workspace.
In the properties of the report used as the subreport, set the default data adapter to the exported file.
Pass the appropriate parameters from the master report to the subreport.
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 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));
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