Congor Posted January 18, 2007 Share Posted January 18, 2007 This is a simple Question I guess, and i thinkive solved it so far, but i wonder if there isn'tanother way for this task. I want to set Text variables from my Java-ApplicationIt is done by a scriplet, right (like in /demo/samples/jcharts) ? Here is the Scriplet: public class OverviewScriptlet extends JRDefaultScriptlet { public void afterReportInit() throws JRScriptletException { ...super.setVariableValue("NameText", "Egon Schmitz"); } } And the Variable in the jasper-xml File [CDATA[$V{NameText}]] Or is there another way for text variables? Thanks in advanceYves Link to comment Share on other sites More sharing options...
Congor Posted January 18, 2007 Author Share Posted January 18, 2007 Ok, i just got it by myself so i guess, this is the solution, and my examplebefore was just for Objects in general... The java code: Map parameters = new HashMap();parameters.put("ReportTitle", "Address Report");JasperFillManager.fillReportToFile(fileName, parameters, getConnection()); And the jrxml-file: <parameter name="ReportTitle" isForPrompting="true" class="java.lang.String"/> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="0" y="0" width="760" height="60" forecolor="#000000" backcolor="#FFFFFF" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" lineSpacing="Single"> <font fontName="Monospaced" pdfFontName="Courier" size="22" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$P{ReportTitle}]]></textFieldExpression> </textField> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now