Jump to content
Changes to the Jaspersoft community edition download ×

Error: Parameter not found : Title


yael

Recommended Posts

I'm tring to set title from java to a xml file with parameter, but I get this error:

Code:

net.sf.jasperreports.engine.JRException: Report design not valid :
1. Parameter not found : Title
at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:267)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144)
at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)
at XmlAndSql.main(XmlAndSql.java:38)

In java code:

Code:
[code]

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;

public class XmlAndSql {

public static void main(String[] args) throws SQLException {

try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"«»);
Connection conn = DriverManager
.getConnection(
"jdbc:«»sqlserver://matarotsrv:1433;databaseName=qm6",
"sa", "sa"«»);

// load JasperDesign from XML and compile it into JasperReport
JasperDesign jasperDesign = JRXmlLoader.load("example2.xml"«»);

// *** this is the line error!!! ***
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

// create a map of parameters to pass to the report.
Map<String,String> parameters = new HashMap<String,String>();
parameters.put("Title", "Customer List"«»);

// create JasperPrint using fillReport() method
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
// You can use JasperPrint to create PDF
JasperExportManager.exportReportToPdfFile(jasperPrint, "example2.pdf"«»);
// Or to view report in the JasperViewer
JasperViewer.viewReport(jasperPrint, true);

} catch (Exception e) {
e.printStackTrace();
}
}
}

In xml:

Code:
[code]
<title>
<band height="50">
<textField>
<reportElement x="0" y="0" width="200" height="50" />
<textFieldExpression class="java.lang.String">$P{Title}</textFieldExpression>
</textField>
</band>
</title>

Please help me with that, I'm biginerr in xml & reports..:unsure:

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...