Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > Jasper
Jasper Forum d'entraide sur Jasper Reports. Avant de poster --> FAQ Jasper, Tutoriels Jasper
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 16/10/2007, 16h11   #1
Invité de passage
 
Inscription : octobre 2006
Messages : 20
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 20
Points : 3
Points : 3
Par défaut Affichage du sous-rapport dans mon rapport principal

Bonjour,

J'ai un modèle de données d'objets Java dont je me sers pour l'affichage dans un rapport PDF
Voici mon modèle de données :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
package fr.test;
 
import java.util.List;
 
public class TechnicienAPRS {
 
	private Integer idTechnicien;
	private String nomTechnicien;
	private String prenomTechnicien;
 
	private List<HabilitationTechnicien> ListeHabilitations;
 
	public Integer getIdTechnicien() {
		return idTechnicien;
	}
 
	public void setIdTechnicien(Integer idTechnicien) {
		this.idTechnicien = idTechnicien;
	}
 
	public String getNomTechnicien() {
		return nomTechnicien;
	}
 
	public void setNomTechnicien(String nomTechnicien) {
		this.nomTechnicien = nomTechnicien;
	}
 
	public String getPrenomTechnicien() {
		return prenomTechnicien;
	}
 
	public void setPrenomTechnicien(String prenomTechnicien) {
		this.prenomTechnicien = prenomTechnicien;
	}
 
	public List<HabilitationTechnicien> getListeHabilitations() {
		return ListeHabilitations;
	}
 
	public void setListeHabilitations(
			List<HabilitationTechnicien> listeHabilitations) {
		ListeHabilitations = listeHabilitations;
	}
}
La classe HabilitationTechnicien est un bean simple :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
package fr.test;
 
public class HabilitationTechnicien {
 
	private Integer idTechnicien;
	private String typeAvion;
 
	public Integer getIdTechnicien() {
		return idTechnicien;
	}
	public void setIdTechnicien(Integer idTechnicien) {
		this.idTechnicien = idTechnicien;
	}
	public String getTypeAvion() {
		return typeAvion;
	}
	public void setTypeAvion(String typeAvion) {
		this.typeAvion = typeAvion;
	}
 
}
Je veux pouvoir afficher la liste d'objets "HabilitationTechnicien" propriété du bean "TechnicienAPRS" à l'aide d'un subreport Jasper.

Pour celà,
j'ai créé un master report avec iReport. En voici le code :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
<?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="Master"
		 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="ListeHabilitations" isForPrompting="false" class="java.util.List"/>
 
	<field name="idTechnicien" class="java.lang.Integer"/>
	<field name="nomTechnicien" class="java.lang.String"/>
	<field name="prenomTechnicien" class="java.lang.String"/>
 
		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="50"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="140"
						y="10"
						width="330"
						height="30"
						key="staticText-1"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
					</textElement>
				<text><![CDATA[Test sous-rapport]]></text>
				</staticText>
			</band>
		</title>
		<pageHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</pageHeader>
		<columnHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnHeader>
		<detail>
			<band height="500"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="40"
						y="6"
						width="80"
						height="20"
						key="staticText-2"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[ID]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="150"
						y="6"
						width="100"
						height="20"
						key="staticText-3"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[NOM]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="269"
						y="5"
						width="100"
						height="20"
						key="staticText-4"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[PRENOM]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="40"
						y="36"
						width="80"
						height="30"
						key="textField-1"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.Integer"><![CDATA[$F{idTechnicien}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="150"
						y="36"
						width="100"
						height="30"
						key="textField-2"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{nomTechnicien}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="270"
						y="36"
						width="100"
						height="30"
						key="textField-3"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{prenomTechnicien}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="160"
						y="76"
						width="150"
						height="30"
						key="staticText-5"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[Type Avion]]></text>
				</staticText>
				<subreport  isUsingCache="true">
					<reportElement
						mode="Opaque"
						x="20"
						y="120"
						width="500"
						height="300"
						key="subreport-1"/>
					<subreportExpression  class="java.lang.String"><![CDATA["C:\\Projets ECLIPSE EUROPA WTP ALL IN 1\\workspace\\SielWEB\\WebContent\\WEB-INF\\reports\\Master_subreport.jasper"]]></subreportExpression>
				</subreport>
			</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>
Le subreport qui m'afficherait la liste de beans "HabilitationTechnicien" est le suivant :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
<?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="Master_subreport"
		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="535"
		 pageHeight="802"
		 columnWidth="535"
		 columnSpacing="0"
		 leftMargin="0"
		 rightMargin="0"
		 topMargin="0"
		 bottomMargin="0"
		 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.*" />
 
 
	<field name="idTechnicien" class="java.lang.Integer"/>
	<field name="typeAvion" 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" >
				<rectangle radius="0" >
					<reportElement
						mode="Opaque"
						x="1"
						y="-19"
						width="534"
						height="17"
						forecolor="#000000"
						backcolor="#999999"
						key="element-22"/>
					<graphicElement stretchType="NoStretch" pen="Thin"/>
				</rectangle>
				<staticText>
					<reportElement
						x="0"
						y="-19"
						width="267"
						height="16"
						forecolor="#FFFFFF"
						key="element-90"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="2" rightBorder="None" rightBorderColor="#000000" rightPadding="2" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font fontName="" size="12"/>
					</textElement>
				<text><![CDATA[idTechnicien]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="267"
						y="-19"
						width="267"
						height="16"
						forecolor="#FFFFFF"
						key="element-90"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="2" rightBorder="None" rightBorderColor="#000000" rightPadding="2" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font fontName="" size="12"/>
					</textElement>
				<text><![CDATA[typeAvion]]></text>
				</staticText>
			</band>
		</columnHeader>
		<detail>
			<band height="19"  isSplitAllowed="true" >
				<line direction="TopDown">
					<reportElement
						x="0"
						y="17"
						width="535"
						height="0"
						forecolor="#808080"
						key="line"
						positionType="FixRelativeToBottom"/>
					<graphicElement stretchType="NoStretch" pen="Thin"/>
				</line>
				<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="1"
						width="267"
						height="15"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="2" rightBorder="None" rightBorderColor="#000000" rightPadding="2" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font fontName="Times-Roman" size="12"/>
					</textElement>
				<textFieldExpression   class="java.lang.Integer"><![CDATA[$F{idTechnicien}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="267"
						y="1"
						width="267"
						height="15"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="2" rightBorder="None" rightBorderColor="#000000" rightPadding="2" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font fontName="Times-Roman" size="12"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{typeAvion}]]></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>
Le problème est que je sais affiché des données dans le master report ainsi que dans le subreport de façon séparée grâce au code suivant :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
package fr.test;
 
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import net.sf.jasperreports.engine.JRDataSource;
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.data.JRBeanArrayDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;
 
 
public class TestJasper {
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		byte[] pdfStream = null;
	    try
	    {
 
	      JRDataSource dataSource = createReportDataSource();
	      // - Paramètres à envoyer au rapport
	      Map parameters = new HashMap();
	      parameters.put("Titre", "Titre");
	      JasperReport jasperReport_Master = JasperCompileManager.
	      			compileReport("C:\\Projets ECLIPSE EUROPA WTP ALL IN 1\\workspace\\" +
	      					"SielWEB\\WebContent\\WEB-INF\\reports\\Master.jrxml");
 
	      JasperReport jasperReport_Subreport = JasperCompileManager.
			compileReport("C:\\Projets ECLIPSE EUROPA WTP ALL IN 1\\workspace\\" +
					"SielWEB\\WebContent\\WEB-INF\\reports\\Master_subreport.jrxml");
 
	      JRDataSource dataSource_subreport = createSubReportDataSource(); 
 
 
	      JasperPrint jasperPrint_Subreport = JasperFillManager.fillReport(jasperReport_Subreport, parameters, dataSource_subreport);
	      JasperPrint jasperPrint_Master = JasperFillManager.fillReport(jasperReport_Master, parameters, dataSource);
 
	      JasperExportManager.exportReportToPdfFile(jasperPrint_Subreport, "C:\\Projets ECLIPSE EUROPA WTP ALL IN 1\\workspace" +
    		"\\SielWEB\\WebContent\\WEB-INF\\reports\\Master_subreport.pdf");
 
	      JasperExportManager.exportReportToPdfFile(jasperPrint_Master, "C:\\Projets ECLIPSE EUROPA WTP ALL IN 1\\workspace" +
	      		"\\SielWEB\\WebContent\\WEB-INF\\reports\\Master.pdf");
 
	    }
	    catch (Exception e)
	    {
	    	e.printStackTrace();
	    }		  
	}
 
 
	private static JRDataSource createReportDataSource()
	{
		JRBeanArrayDataSource dataSource;
		TechnicienAPRS[] reportRows = initializeBeanArray();
		dataSource = new JRBeanArrayDataSource(reportRows);
		return dataSource;
	}
 
	private static JRDataSource createSubReportDataSource()
	{
		JRBeanArrayDataSource dataSource;
		Object[] listeHabilitations = initializeBeanArrayHabilitations();
		dataSource = new JRBeanArrayDataSource(listeHabilitations);
		return dataSource;
	}
 
 
	private static Object[] initializeBeanArrayHabilitations() {
		TechnicienAPRS technicienAPRS = getModelReport()[0];
		List<HabilitationTechnicien> listeHabilitations = technicienAPRS.getListeHabilitations();
		HabilitationTechnicien[] arrayHabilitationTechniciens = new HabilitationTechnicien[listeHabilitations.size()];
		for (int i = 0; i < arrayHabilitationTechniciens.length; i++) {
			arrayHabilitationTechniciens[i] = listeHabilitations.get(i);
		}
		return arrayHabilitationTechniciens;
	}
 
	private static TechnicienAPRS[] getModelReport()
	{
		TechnicienAPRS[] reportRows = new TechnicienAPRS[1];
 
		List<HabilitationTechnicien> listeHabilitations = new ArrayList<HabilitationTechnicien>(2);
		HabilitationTechnicien habilitationTechnicien1 = new HabilitationTechnicien();
		habilitationTechnicien1.setIdTechnicien(1);
		habilitationTechnicien1.setTypeAvion("CRJ100");
		listeHabilitations.add(habilitationTechnicien1);
 
		HabilitationTechnicien habilitationTechnicien2 = new HabilitationTechnicien();
		habilitationTechnicien2.setIdTechnicien(1);
		habilitationTechnicien2.setTypeAvion("CRJ700");
		listeHabilitations.add(habilitationTechnicien2);
 
		TechnicienAPRS technicienAPRS = new TechnicienAPRS();
		technicienAPRS.setIdTechnicien(1);
		technicienAPRS.setNomTechnicien("DUPONT");
		technicienAPRS.setPrenomTechnicien("Jean");
//		technicienAPRS.setHabilitationTechnicien(habilitationTechnicien1);
		technicienAPRS.setListeHabilitations(listeHabilitations);
		reportRows[0] = technicienAPRS;
		return reportRows;
	}
 
	private static TechnicienAPRS[] initializeBeanArray()
	{
		return getModelReport();
	}
}
Mes 2 fichiers PDF générés : "Master.pdf" et "Master_subreport.pdf" contiennent bien les données.
Mais comment générer le "Master.pdf" en y incluant les données du sous-rapport avec les API JASPER ????
Merci pour votre aide précieuse ...
gbruno est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/10/2007, 00h05   #2
Membre habitué
 
Inscription : avril 2005
Messages : 119
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 119
Points : 122
Points : 122
Envoyer un message via MSN à egwada Envoyer un message via Yahoo à egwada
Slt !

Je n'ai pas bien lu ton code. Mais il faut que le rapport principal transmette la source de données au sous-rapport.

Avec iReport tu peux normalement tester ton rapport complètement. Si tu exécutes le rapport donc il ne devrait pas fonctionner parce que le sous-rapport n'aura pas de source.

Bien à toi.
__________________
E-Gwada
===============================
site developpez.com : http://charly-clairmont.developpez.com
site pro : http://www.altic.org
egwada est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/10/2007, 09h38   #3
Invité de passage
 
Inscription : octobre 2006
Messages : 20
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 20
Points : 3
Points : 3
Salut,
et comment tu code ça en Java ?
gbruno est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/10/2007, 23h29   #4
Membre actif
 
Avatar de tnodev
 
Inscription : mai 2005
Messages : 160
Détails du profil
Informations personnelles :
Âge : 40
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : mai 2005
Messages : 160
Points : 155
Points : 155
Salut

Une JRDatasource par report, donc tu définis ton report principal dans lequel :
  1. tu définis les champs correspondant inclus la liste des habilitations
  2. tu envoies ta liste de technicien en tant que JrDatasource principal
  3. tu inclus ton sous-report qui va afficher les habilitations en lui donnant en paramètre une JrBeanCollectionDatasource de ta listHabilitation (à vérifier, je fais ça de mémoire...)
  4. quelques réglages de ci de là
  5. c'est merveilleux ça marche !
tnodev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/03/2008, 16h43   #5
Membre du Club
 
Inscription : mars 2007
Messages : 36
Détails du profil
Informations personnelles :
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : mars 2007
Messages : 36
Points : 40
Points : 40
Salut,
Je viens d'avoir besoin de faire la même chose, c'est effectivement tout comme tu le dis tnodev.

Cependant, je me permets de détailler un peu plus, car je n'étais pas trop à l'aise sur la façon de donner la JRBeanCollectionDataSource au sous rapport et j'ai du chercher une explication un peu plus détaillée, que j'ai trouvée sur JasperForge

Donc voilà, en l'applicant à l'exemple ci-dessus, le rapport principal aura donc un field ListeHabilitations, et le sous rapport aura comme datasource :
Code :
new JRBeanCollectionDataSource($F{ListeHabilitations})
A+
Sthocs est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h12.


 
 
 
 
Partenaires

Hébergement Web