KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > utility > PoolStatus


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.utility;
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.erpCommon.businessUtility.WindowTabs;
25 import java.io.*;
26
27 import javax.servlet.*;
28 import javax.servlet.http.*;
29
30
31
32 public class PoolStatus extends HttpSecureAppServlet {
33   
34
35   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
36     VariablesSecureApp vars = new VariablesSecureApp(request);
37
38     if (vars.commandIn("DEFAULT", "REFRESH")) {
39       printPageMenuPoolStatus(response, vars);
40     }
41   }
42
43
44   void printPageMenuPoolStatus (HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException {
45     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
46
47     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/utility/PoolStatus").createXmlDocument();
48     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
49     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
50
51     xmlDocument.setParameter("status", formatearTextoJavascript(getPoolStatus()));
52     xmlDocument.setParameter("body", "");
53     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "SetPriority", false, "", "", "",false, "utility", strReplaceWith, false, true);
54     toolbar.prepareSimpleToolBarTemplate();
55     xmlDocument.setParameter("toolbar", toolbar.toString());
56     try {
57       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_forms.ShowSession");
58       xmlDocument.setParameter("theme", vars.getTheme());
59       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "PoolStatus.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
60       xmlDocument.setParameter("navigationBar", nav.toString());
61       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "PoolStatus.html", strReplaceWith);
62       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
63     } catch (Exception JavaDoc ex) {
64       throw new ServletException(ex);
65     }
66
67     {
68       OBError myMessage = vars.getMessage("PoolStatus");
69       vars.removeMessage("PoolStatus");
70       if (myMessage!=null) {
71         xmlDocument.setParameter("messageType", myMessage.getType());
72         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
73         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
74       }
75     }
76
77     response.setContentType("text/html; charset=UTF-8");
78     PrintWriter out = response.getWriter();
79     out.println(xmlDocument.print());
80     out.close();
81   }
82
83   // replaces the linebreak character and the enter carriage with \n and \r, in order to make it identify just the in the second reading
84
public String JavaDoc formatearTextoJavascript(String JavaDoc strTexto) {
85     int pos;
86     while (strTexto.indexOf('\r')!=-1) {
87       pos = strTexto.indexOf('\r');
88       strTexto = strTexto.substring(0, pos)+ "<br>" + strTexto.substring(pos +1, strTexto.length());
89     }
90
91     while (strTexto.indexOf('\n')!=-1) {
92       pos = strTexto.indexOf('\n');
93       strTexto = strTexto.substring(0, pos)+ "<br>" + strTexto.substring(pos +1, strTexto.length());
94     }
95     return strTexto;
96  
97   }
98   public String JavaDoc getServletInfo() {
99     return "Protected resources Servlet";
100   } // end of getServletInfo() method
101
}
102
Popular Tags