Jump to content
We've recently updated our Privacy Statement, available here ×

Help with SubReport


howudodat

Recommended Posts

I am really struggling trying to get my head around this subreport.  I've got both reports working independantly and can't get them hooked together.  The basic idea is a panel that allows a user to select N number of people, and for each person select from a table the information they want displayed.  To simulate this I built this simple set of maps:

String [] clients = new String[] {"Peter", "Bob", "Alice", "Sue", "Tom" };Vector<HashMap<String, String>>contacts = new Vector<HashMap<String, String>>();Vector< HashMap<String, String>>contactinfo = new Vector<HashMap<String, String>>();for (int x=0; x<5; x++) {	HashMap<String, String>row = new HashMap<String, String>();	row.put("id", ""+x);	row.put("name", clients[x]);	contacts.add(row);					String [] strs = new String[] {"phone", "fax", "email" };	for (String s : strs) {		HashMap<String, String>rowi = new HashMap<String, String>();		rowi.put("client", ""+x);		rowi.put("info", s+" for client:"+clients[x]);		contactinfo.add(rowi);	}}

Each of the rwo reports load fine independantly:
1:  list of contact names
2:  list of contact info

I can embed the sub report, but how do I link the contact 'id' with the contactinfo 'client' field?

Also can the xml of a sub report be embedded directly, or does it need to be in its own file and the file be referenced with:
<subreportExpression class="java.lang.String"><![CDATA["reports/srptContactInfo.jasper"]]>

Peter

Code:
Main Report:	<field name="name" class="java.lang.String"/>	<pageHeader>		<band height="60">			<staticText>				<reportElement x="0" y="0" width="112" height="24"/>				<textElement verticalAlignment="Bottom"/>				<text><![CDATA[Name:]]></text>			</staticText>			<textField>				<reportElement x="112" y="10" width="372" height="14"/>				<textElement textAlignment="Center">					<font isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>			</textField>		</band>	</pageHeader>	<detail>		<band height="505">			<subreport>				<reportElement x="0" y="0" width="572" height="505"/>				<subreportParameter name="state">					<subreportParameterExpression>						<![CDATA[$P{client}]]>					</subreportParameterExpression>				</subreportParameter>				<subreportExpression class="java.lang.String"><![CDATA["reports/srptContactInfo.jasper"]]></subreportExpression>			</subreport>		</band>	</detail>SubReport:	<field name="info" class="java.lang.String"/>	<columnHeader>		<band height="25">			<staticText>				<reportElement x="0" y="0" width="112" height="24"/>				<textElement verticalAlignment="Bottom"/>				<text><![CDATA[info:]]></text>			</staticText>		</band>	</columnHeader>	<detail>		<band height="30">			<textField>				<reportElement x="0" y="0" width="100" height="20"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{info}]]></textFieldExpression>			</textField>		</band>	</detail>
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...