hq4ever Posted October 2, 2007 Share Posted October 2, 2007 Hello I'm new to jasper and java as a whole.I would like to know how I can get access to the jasperreport object from within the jrxml file? I would like to print the name I'm giving to the report. Thank's for your help guys, happy reporting to us all. Link to comment Share on other sites More sharing options...
lucianc Posted October 11, 2007 Share Posted October 11, 2007 There is no (built-in) way to do that. You can post a feature request here. Regards,Lucian Link to comment Share on other sites More sharing options...
momzilla Posted December 15, 2007 Share Posted December 15, 2007 Here's a kludge to get the objectname: Make a variable $V{tester}[initial value expression]this.getClass().getName().substring(0,this.getClass().getName().lastIndexOf('_')) [Variable Expression]$V{tester}.substring(0,$V{tester}.lastIndexOf('_')) then drop a textfield onto your report[textfield expression]$V{tester}.substring(0,$V{tester}.lastIndexOf('_')) Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted December 17, 2007 Share Posted December 17, 2007 Just pass the name in as a parameter, and set the parameter to have a default value of the name you assign to the report. Edit: As an example:Code:<?xml version="1.0" encoding="UTF-8"?><!-- Created using JasperAssistant (http://www.jasperassistant.com) --><!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="Unnamed" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30"> <property name="com.jasperassistant.designer.Grid" value="false"/> <property name="com.jasperassistant.designer.SnapToGrid" value="false"/> <property name="com.jasperassistant.designer.GridWidth" value="12"/> <property name="com.jasperassistant.designer.GridHeight" value="12"/> <parameter name="REPORT_NAME" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["My Sample Report"]]></defaultValueExpression> </parameter> <detail> <band height="100"> <textField> <reportElement x="40" y="9" width="132" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_NAME}]]></textFieldExpression> </textField> </band> </detail></jasperReport> HTH,RobinPost edited by: rsilver@ns.sympatico.ca, at: 2007/12/17 14:21 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