details:   https://code.openbravo.com/erp/devel/pi/rev/0c8d2174716f
changeset: 33950:0c8d2174716f
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Fri May 11 15:30:31 2018 +0200
summary:   related to issue 38518: use renderJR to compile the subreport

  Refactored the report generation to demonstrate how renderJR method can be 
used to compile the sub-reports.

diffstat:

 src/org/openbravo/erpReports/RptM_Requisition.java  |  29 +++++++-------------
 src/org/openbravo/erpReports/RptM_Requisition.jrxml |   3 +-
 2 files changed, 12 insertions(+), 20 deletions(-)

diffs (89 lines):

diff -r 4fa9879b9647 -r 0c8d2174716f 
src/org/openbravo/erpReports/RptM_Requisition.java
--- a/src/org/openbravo/erpReports/RptM_Requisition.java        Fri May 11 
15:03:03 2018 +0200
+++ b/src/org/openbravo/erpReports/RptM_Requisition.java        Fri May 11 
15:30:31 2018 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2018 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -26,12 +26,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import net.sf.jasperreports.engine.JRException;
-import net.sf.jasperreports.engine.JasperReport;
-
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
-import org.openbravo.client.application.report.ReportingUtils;
 
 public class RptM_Requisition extends HttpSecureAppServlet {
   private static final long serialVersionUID = 1L;
@@ -49,8 +45,9 @@
       String strmRequisitionId = 
vars.getSessionValue("RptM_Requisition.inpmRequisitionId_R");
       if (strmRequisitionId.equals(""))
         strmRequisitionId = 
vars.getSessionValue("RptM_Requisition.inpmRequisitionId");
-      if (log4j.isDebugEnabled())
+      if (log4j.isDebugEnabled()) {
         log4j.debug("+***********************: " + strmRequisitionId);
+      }
       printPagePartePDF(response, vars, strmRequisitionId);
     } else
       pageError(response);
@@ -58,25 +55,19 @@
 
   private void printPagePartePDF(HttpServletResponse response, 
VariablesSecureApp vars,
       String strmRequisitionId) throws IOException, ServletException {
-    if (log4j.isDebugEnabled())
+    if (log4j.isDebugEnabled()) {
       log4j.debug("Output: pdf");
-    String strBaseDesign = getBaseDesignPath(vars.getLanguage());
-
+    }
     HashMap<String, Object> parameters = new HashMap<String, Object>();
-    JasperReport jasperReportLines;
-    try {
-      jasperReportLines = ReportingUtils.compileReport(strBaseDesign
-          + "/org/openbravo/erpReports/RptM_Requisition_Lines.jrxml");
-    } catch (JRException e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    }
-
-    parameters.put("SR_LINES", jasperReportLines);
     parameters.put("REQUISITION_ID", strmRequisitionId);
     renderJR(vars, response, null, "pdf", parameters, null, null);
   }
 
+  @Override
+  protected boolean renderJRShouldCompileSubreports() {
+    return true;
+  }
+
   public String getServletInfo() {
     return "Servlet that presents the RptMRequisitions seeker";
   } // End of getServletInfo() method
diff -r 4fa9879b9647 -r 0c8d2174716f 
src/org/openbravo/erpReports/RptM_Requisition.jrxml
--- a/src/org/openbravo/erpReports/RptM_Requisition.jrxml       Fri May 11 
15:03:03 2018 +0200
+++ b/src/org/openbravo/erpReports/RptM_Requisition.jrxml       Fri May 11 
15:30:31 2018 +0200
@@ -61,6 +61,7 @@
        <parameter name="LANGUAGE" class="java.lang.String">
                
<defaultValueExpression><![CDATA["en_US"]]></defaultValueExpression>
        </parameter>
+       <parameter name="SUBREP_RptM_Requisition_Lines" 
class="net.sf.jasperreports.engine.JasperReport" isForPrompting="false"/>
        <queryString>
                <![CDATA[SELECT M_REQUISITION.M_REQUISITION_ID, 
M_REQUISITION.DOCUMENTNO,
        AD_COLUMN_IDENTIFIER(to_char('AD_User'), 
to_char(M_REQUISITION.AD_USER_ID), $P{LANGUAGE}) AS REQUESTER,
@@ -200,7 +201,7 @@
                                        
<subreportParameterExpression><![CDATA[$P{LOCALE}]]></subreportParameterExpression>
                                </subreportParameter>
                                
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
-                               
<subreportExpression><![CDATA[$P{SR_LINES}]]></subreportExpression>
+                               
<subreportExpression><![CDATA[$P{SUBREP_RptM_Requisition_Lines}]]></subreportExpression>
                        </subreport>
                </band>
        </detail>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to