KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_forms > DebtPaymentUnapply


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
20 package org.openbravo.erpCommon.ad_forms;
21
22 import org.openbravo.erpCommon.utility.ToolBar;
23
24 import org.openbravo.erpCommon.utility.*;
25 import org.openbravo.erpCommon.businessUtility.WindowTabs;
26 import org.openbravo.base.secureApp.HttpSecureAppServlet;
27 import org.openbravo.base.secureApp.VariablesSecureApp;
28 import org.openbravo.xmlEngine.XmlDocument;
29 import java.io.*;
30 import javax.servlet.*;
31 import javax.servlet.http.*;
32
33
34 public class DebtPaymentUnapply extends HttpSecureAppServlet {
35   
36
37   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
38     VariablesSecureApp vars = new VariablesSecureApp(request);
39
40     if (!Utility.hasFormAccess(this, vars, "", "org.openbravo.erpCommon.ad_forms.DebtPaymentUnapply")) {
41       bdError(response, "AccessTableNoView", vars.getLanguage());
42       return;
43     }
44
45     if (vars.commandIn("DEFAULT")) {
46       printPageDataSheet(response, vars);
47     } else if (vars.commandIn("PROCESS")) {
48       String JavaDoc strCDebtPaymentId = vars.getInStringParameter("inpDebtPayment");
49       if (strCDebtPaymentId.equals("")) strCDebtPaymentId = "('0')";
50       int i = updateSelection(strCDebtPaymentId);
51       vars.setSessionValue("DebtPaymentUnapply|message", "Updated = " + Integer.toString(i));
52       response.sendRedirect(strDireccion + request.getServletPath());
53      } else pageError(response);
54   }
55
56   int updateSelection(String JavaDoc strCDebtPaymentId)
57     throws IOException, ServletException {
58     DebtPaymentUnapplyData [] data = DebtPaymentUnapplyData.selectRecord(this, strCDebtPaymentId);
59     int i=0;
60     for (i=0;i<data.length;i++) {
61       if (data[i].iscancel.equals("N")){
62         DebtPaymentUnapplyData.updateGenerate(this, data[i].cDebtPaymentId);
63       }else{
64         DebtPaymentUnapplyData.updateCancel(this, data[i].cDebtPaymentId);
65       }
66     }
67     return i;
68   }
69
70
71   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars)
72     throws IOException, ServletException {
73     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
74     response.setContentType("text/html; charset=UTF-8");
75     PrintWriter out = response.getWriter();
76     String JavaDoc discard[]={"sectionDetail"};
77     XmlDocument xmlDocument=null;
78     DebtPaymentUnapplyData[] data=null;
79     data = DebtPaymentUnapplyData.select(this, vars.getLanguage());
80     if (data==null || data.length == 0) {
81      xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_forms/DebtPaymentUnapply", discard).createXmlDocument();
82      data = DebtPaymentUnapplyData.set();
83     } else {
84      xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_forms/DebtPaymentUnapply").createXmlDocument();
85     }
86
87     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "DebtPaymentUnapply", false, "", "", "",false, "ad_forms", strReplaceWith, false, true);
88     toolbar.prepareSimpleToolBarTemplate();
89     xmlDocument.setParameter("toolbar", toolbar.toString());
90
91     try {
92       KeyMap key = new KeyMap(this, vars, "DebtPaymentUnapply.html");
93       xmlDocument.setParameter("keyMap", key.getActionButtonKeyMaps());
94     } catch (Exception JavaDoc ex) {
95       throw new ServletException(ex);
96     }
97     try {
98       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_forms.DebtPaymentUnapply");
99       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
100       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
101       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
102       xmlDocument.setParameter("theme", vars.getTheme());
103       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "DebtPaymentUnapply.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
104       xmlDocument.setParameter("navigationBar", nav.toString());
105       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "DebtPaymentUnapply.html", strReplaceWith);
106       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
107     } catch (Exception JavaDoc ex) {
108       throw new ServletException(ex);
109     }
110     {
111       OBError myMessage = vars.getMessage("DebtPaymentUnapply");
112       vars.removeMessage("DebtPaymentUnapply");
113       if (myMessage!=null) {
114         xmlDocument.setParameter("messageType", myMessage.getType());
115         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
116         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
117       }
118     }
119
120     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
121     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
122     xmlDocument.setData("structure1", data);
123     out.println(xmlDocument.print());
124     out.close();
125   }
126
127   public String JavaDoc getServletInfo() {
128     return "Servlet DebtPaymentUnapply. This Servlet was made by Eduardo Argal";
129   } // end of getServletInfo() method
130
}
131
132
Popular Tags