title: How to pass parameters and resource bundle from master report to subreport
body: <p>Currently I'm using <em>JasperReports</em> to generate pdfs displaying a list of payments, one entity per page. Code for that (for one entity):</p>
  
  <pre><code> Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;();
   JasperReport jasperReport = (JasperReport) JRLoader.loadObjectFromFile(path + "WEB-INF/jasper/PaymentOrder.jasper");
                  report = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
  </code></pre>
  
  <p>What I need to do is to display two enitities in one file. I'm trying to use subreports to do that. </p>
  
  <ol>
  <li>How can I pass a Map with parameters to my subreport? </li>
  <li>And how to I change my subreport file (if needed) to get parameters from parent?</li>
  <li>How can I pass ResourceBundle from master report to subreport?</li>
  <li>How can I set the name of subreport?</li>
  </ol>
  
  <p>Master report:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"&gt;
      &lt;title&gt;
          &lt;band height="531" splitType="Stretch"&gt;
              &lt;textField isBlankWhenNull="true"&gt;
                  &lt;reportElement x="0" y="0" width="555" height="20"/&gt;
                  &lt;textElement verticalAlignment="Middle"&gt;
                      &lt;font fontName="Times New Roman" isUnderline="false" pdfEncoding="UTF-8" isPdfEmbedded="true"/&gt;
                  &lt;/textElement&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA["* MASTER REPORT *"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;subreport runToBottom="false"&gt;
                  &lt;reportElement positionType="Float" x="0" y="55" width="555" height="15" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/&gt;
                  &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_PARAMETERS_MAP}.get( "subReport1Params" )]]&gt;&lt;/dataSourceExpression&gt;
                  &lt;subreportExpression&gt;&lt;![CDATA[$P{REPORT_PARAMETERS_MAP}.get( "subReport1" )]]&gt;&lt;/subreportExpression&gt;
              &lt;/subreport&gt;
          &lt;/band&gt;
      &lt;/title&gt;
  &lt;/jasperReport&gt; 
  </code></pre>
  
  <p>Subreport:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"&gt;
      &lt;title&gt;
          &lt;band height="531" splitType="Stretch"&gt;
              &lt;textField isBlankWhenNull="true"&gt;
                  &lt;reportElement x="0" y="0" width="555" height="20"/&gt;
                  &lt;textElement verticalAlignment="Middle"&gt;
                      &lt;font fontName="Times New Roman" isUnderline="false" pdfEncoding="UTF-8" isPdfEmbedded="true"/&gt;
                  &lt;/textElement&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$P{REPORT_RESOURCE_BUNDLE}.getString( "user" ) + ": "+$P{REPORT_PARAMETERS_MAP}.get( "user" )]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isBlankWhenNull="true"&gt;
                  &lt;reportElement x="0" y="22" width="555" height="22"/&gt;
                  &lt;textElement textAlignment="Center" verticalAlignment="Middle"&gt;
                      &lt;font fontName="Times New Roman" isUnderline="false" pdfEncoding="UTF-8" isPdfEmbedded="true"/&gt;
                  &lt;/textElement&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$P{REPORT_RESOURCE_BUNDLE}.getString( "payment" ) + " № "+$P{REPORT_PARAMETERS_MAP}.get( "docNumber" )+" "+$P{REPORT_RESOURCE_BUNDLE}.getString( "from" ) + " "+$P{REPORT_PARAMETERS_MAP}.get( "date" )]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>java code:</p>
  
  <pre><code>HashMap&lt;String, Object&gt; parameters = getParametersForPayment(doc1, user, locale);
  String path = ((WebApplication) Application.get()).getServletContext().getRealPath("/");
  
  File fileSubReport1 = new File(path + "WEB-INF/jasper/PaymentOrder.jasper");
  parameters.put("subReport1", JRLoader.loadObject(fileSubReport1));
  
  
  File f = new File(path + "WEB-INF/jasper/PaymentMaster.jasper");
  JasperReport jasperReport = (JasperReport) JRLoader.loadObject(f);
  report = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
  </code></pre>