KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_callouts > SE_Wh_SchedulePeriod


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.erpCommon.ad_callouts;
20
21 import org.openbravo.base.secureApp.HttpSecureAppServlet;
22 import org.openbravo.base.secureApp.VariablesSecureApp;
23 import org.openbravo.xmlEngine.XmlDocument;
24 import org.openbravo.utils.FormatUtilities;
25 import org.openbravo.erpCommon.utility.*;
26 import org.openbravo.erpCommon.ad_actionButton.*;
27 import java.io.*;
28 import javax.servlet.*;
29 import javax.servlet.http.*;
30
31
32 public class SE_Wh_SchedulePeriod extends HttpSecureAppServlet {
33   
34
35   public void init (ServletConfig config) {
36     super.init(config);
37     boolHist = false;
38   }
39
40   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
41     VariablesSecureApp vars = new VariablesSecureApp(request);
42     if (vars.commandIn("DEFAULT")) {
43       String JavaDoc strChanged = vars.getStringParameter("inpLastFieldChanged");
44       if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged);
45       String JavaDoc strWhSchedule = vars.getStringParameter("inpmWhScheduleId");
46       String JavaDoc strTabId = vars.getStringParameter("inpTabId");
47       
48       try {
49         printPage(response, vars, strWhSchedule, strTabId);
50       } catch (ServletException ex) {
51         pageErrorCallOut(response);
52       }
53     } else pageError(response);
54   }
55
56   void printPage(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strWhSchedule, String JavaDoc strTabId) throws IOException, ServletException {
57     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
58     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
59     
60     InvoicingScheduleData[] data = InvoicingScheduleData.selectM_WH_Period_ID(this, Utility.getContext(this, vars, "#User_Org", "SE_Wh_SchedulePeriod"), Utility.getContext(this, vars, "#User_Client", "SE_Wh_SchedulePeriod"), strWhSchedule);
61     StringBuffer JavaDoc resultado = new StringBuffer JavaDoc();
62     if (data==null || data.length==0) resultado.append("var respuesta = null;");
63     else {
64       resultado.append("var calloutName='SE_Wh_SchedulePeriod';\n\n");
65       resultado.append("var respuesta = new Array(");
66       resultado.append("new Array(\"inpPeriodFromId\", ");
67       if (data!=null && data.length>0) {
68         resultado.append("new Array(");
69         for (int i=0;i<data.length;i++) {
70           resultado.append("new Array(\"" + data[i].id + "\", \"" + FormatUtilities.replaceJS(data[i].name) +"\")");
71           if (i<data.length-1) resultado.append(",\n");
72         }
73         resultado.append("\n)");
74       } else resultado.append("null");
75       resultado.append("\n),");
76       resultado.append("new Array(\"inpPeriodToId\", ");
77       if (data!=null && data.length>0) {
78         resultado.append("new Array(");
79         for (int i=0;i<data.length;i++) {
80           resultado.append("new Array(\"" + data[i].id + "\", \"" + FormatUtilities.replaceJS(data[i].name) +"\")");
81           if (i<data.length-1) resultado.append(",\n");
82         }
83         resultado.append("\n)");
84       } else resultado.append("null");
85       resultado.append("\n)");
86
87       resultado.append(");");
88     }
89     xmlDocument.setParameter("array", resultado.toString());
90     xmlDocument.setParameter("frameName", "frameAplicacion");
91     response.setContentType("text/html; charset=UTF-8");
92     PrintWriter out = response.getWriter();
93     out.println(xmlDocument.print());
94     out.close();
95   }
96 }
97
Popular Tags