Jump to content
Changes to the Jaspersoft community edition download ×

miguelcadavieco


miguelcadavieco

Recommended Posts

hi again, my new problem is the next:

 

I try to send a paramater to a simple report and I can't. This is my report

 

 

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="contenedor"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<property name="ireport.scriptlethandling" value="0" />

<property name="ireport.encoding" value="UTF-8" />

<import value="java.util.*" />

<import value="net.sf.jasperreports.engine.*" />

<import value="net.sf.jasperreports.engine.data.*" />

 

<parameter name="PARAM_PRUEBA" isForPrompting="false" class="java.lang.String">

<defaultValueExpression ><![CDATA[new String ("vaya mierda")]]></defaultValueExpression>

</parameter>

 

<field name="PARAM_PRUEBA" class="java.lang.String"/>

 

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="0" isSplitAllowed="true" >

</band>

</title>

<pageHeader>

<band height="0" isSplitAllowed="true" >

</band>

</pageHeader>

<columnHeader>

<band height="0" isSplitAllowed="true" >

</band>

</columnHeader>

<detail>

<band height="700" isSplitAllowed="true" >

<staticText>

<reportElement

x="17"

y="173"

width="272"

height="65"

key="staticText-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement textAlignment="Justified" verticalAlignment="Middle">

<font size="36" isBold="false"/>

</textElement>

<text><![CDATA[MI PRUEBA]]></text>

</staticText>

<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

mode="Opaque"

x="15"

y="245"

width="76"

height="12"

key="textField-1"/>

<box topBorder="1Point" topBorderColor="#000000" leftBorder="1Point" leftBorderColor="#000000" leftPadding="2" rightBorder="1Point" rightBorderColor="#000000" bottomBorder="1Point" bottomBorderColor="#000000"/>

<textElement>

<font size="8" isBold="true"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{PARAM_PRUEBA}]]></textFieldExpression>

</textField>

</band>

</detail>

<columnFooter>

<band height="0" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="0" isSplitAllowed="true" >

</band>

</pageFooter>

<summary>

<band height="0" isSplitAllowed="true" >

</band>

</summary>

</jasperReport>

 

 

and this is my java source code. I include this code into a jdeveloper servlet

 

 

JasperReport miReport;

JasperReport otroReport;

JasperPrint jasperPrint;

Map masterParams = new HashMap();

 

 

try {

miReport = JasperCompileManager.compileReport("Y:\Web\webProject\Modelos\servletJasper\public_html\WEB-INF\reports\contenedor.jrxml");

otroReport = JasperCompileManager.compileReport("Y:\Web\webProject\Modelos\servletJasper\public_html\WEB-INF\reports\report1.jrxml");

 

String Prueba="hola";

masterParams.put("PARAM_PRUEBA",Prueba);

 

jasperPrint = JasperFillManager.fillReport(miReport,masterParams,new JREmptyDataSource());

 

byte[] pdfasbytes = JasperExportManager.exportReportToPdf(jasperPrint);

 

ServletOutputStream outstream = response.getOutputStream();

response.setContentType("application/pdf");

response.setContentLength(pdfasbytes.length);

 

response.setHeader("Content-disposition",

"inline; filename="Report.pdf"");

outstream.write(pdfasbytes);

 

JasperExportManager.exportReportToPdfFile(jasperPrint, "Y:\Web\webProject\Modelos\servletJasper\public_html\WEB-INF\reports\simple_report.pdf");

 

} catch (JRException e) {

e.printStackTrace();

}

 

}

 

Some idea: I reades the tutorial, the examples and It's simple...but i can't send a parameter to my master report. One more thing: I saw the pdf file into the web browser but don't send the parameters

Link to comment
Share on other sites

  • Replies 0
  • 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...