KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpReports > RptC_OrderPO


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.erpReports;
20
21 import org.openbravo.base.secureApp.*;
22 import java.io.*;
23 import javax.servlet.*;
24 import javax.servlet.http.*;
25 import java.util.*;
26
27 import net.sf.jasperreports.engine.*;
28 import org.openbravo.erpCommon.utility.PrintJRData;
29 import org.openbravo.utils.Replace;
30 import net.sf.jasperreports.engine.design.JasperDesign;
31 import java.sql.Connection JavaDoc;
32 import net.sf.jasperreports.engine.xml.JRXmlLoader;
33 import org.openbravo.erpCommon.utility.JRFormatFactory;
34
35 public class RptC_OrderPO extends HttpSecureAppServlet {
36   
37   
38   public void init (ServletConfig config) {
39     super.init(config);
40     boolHist = false;
41   }
42
43   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
44     VariablesSecureApp vars = new VariablesSecureApp(request);
45
46     if (vars.commandIn("DEFAULT")) {
47       String JavaDoc strcOrderId = vars.getSessionValue("RptC_OrderPO.inpcOrderId_R");
48       if (strcOrderId.equals("")) strcOrderId = vars.getSessionValue("RptC_OrderPO.inpcOrderId");
49       if (log4j.isDebugEnabled()) log4j.debug("+***********************: " + strcOrderId);
50       printPagePartePDF(response, vars, strcOrderId);
51     } else pageError(response);
52   }
53
54
55    void printPagePartePDF(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strcOrderId) throws IOException,ServletException{
56     if (log4j.isDebugEnabled()) log4j.debug("Output: pdf");
57     String JavaDoc strLanguage = vars.getLanguage();
58     if (strBaseDesignPath.endsWith("/")) strDefaultDesignPath = strDefaultDesignPath.substring(0, strDefaultDesignPath.length()-1);
59     log4j.info("*********************Base path: " + strBaseDesignPath);
60     String JavaDoc strNewAddBase = strDefaultDesignPath;
61     String JavaDoc strFinal = strBaseDesignPath;
62     if (!strLanguage.equals("") && !strLanguage.equals("en_US")) strNewAddBase = strLanguage;
63     if (!strFinal.endsWith("/" + strNewAddBase)) strFinal += "/" + strNewAddBase;
64     log4j.info("*********************Base path: " + strFinal);
65     String JavaDoc strBaseDesign = prefix + "/" + strFinal;
66     
67     HashMap<String JavaDoc, Object JavaDoc> parameters = new HashMap<String JavaDoc, Object JavaDoc>();
68     JasperReport jasperReportLines;
69     try {
70       JasperDesign jasperDesignLines = JRXmlLoader.load(strBaseDesign+"/org/openbravo/erpReports/RptC_OrderPO_Lines.jrxml");
71       jasperReportLines = JasperCompileManager.compileReport(jasperDesignLines);
72     } catch (JRException e){
73       e.printStackTrace();
74       throw new ServletException(e.getMessage());
75     }
76     parameters.put("SR_LINES", jasperReportLines);
77     System.out.println("************ " + strReplaceWithFull);
78     System.out.println("************ " + strcOrderId);
79
80     parameters.put("ORDER_ID", strcOrderId);
81     renderJR(vars, response, null, "pdf", parameters, null, null);
82   }
83
84   public String JavaDoc getServletInfo() {
85     return "Servlet that presents the RptCOrders seeker";
86   } // End of getServletInfo() method
87
}
88
Popular Tags