1 19 20 package org.openbravo.erpCommon.businessUtility; 21 22 import java.io.*; 23 24 import javax.servlet.*; 25 import javax.servlet.http.*; 26 27 import org.openbravo.base.secureApp.HttpSecureAppServlet; 28 import org.openbravo.base.secureApp.VariablesSecureApp; 29 import org.openbravo.xmlEngine.XmlDocument; 30 import org.openbravo.erpCommon.utility.Utility; 31 32 33 public class MessageJS extends HttpSecureAppServlet { 34 35 public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { 36 VariablesSecureApp vars = new VariablesSecureApp(request); 37 38 String strValue = vars.getRequiredStringParameter("inpvalue"); 39 printPage(response, vars, strValue); 40 } 41 42 private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strValue) throws IOException, ServletException { 43 if (log4j.isDebugEnabled()) log4j.debug("Output: print page message"); 44 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/businessUtility/MessageJS").createXmlDocument(); 45 String type = "Hidden"; 46 String title = ""; 47 String description = ""; 48 String strLanguage = vars.getStringParameter("inplanguage"); 49 if (strLanguage==null || strLanguage.equals("")) strLanguage = vars.getLanguage(); 50 MessageJSData[] data = null; 51 try { 52 data = MessageJSData.getMessage(this, strLanguage, strValue); 53 } catch (Exception ex) { 54 type = "Error"; 55 title = "Error"; 56 description = ex.toString(); 57 } 58 if (data!=null && data.length>0) { 59 type = (data[0].msgtype.equals("E")?"Error":(data[0].msgtype.equals("I")?"Info":"Warning")); 60 title = Utility.messageBD(this, type, strLanguage); 61 description = "<![CDATA[" + data[0].msgtext + "]]>"; 62 } 63 xmlDocument.setParameter("type", type); 64 xmlDocument.setParameter("title", title); 65 xmlDocument.setParameter("description", description); 66 response.setContentType("text/xml; charset=UTF-8"); 67 response.setHeader("Cache-Control", "no-cache"); 68 PrintWriter out = response.getWriter(); 69 if (log4j.isDebugEnabled()) log4j.debug(xmlDocument.print()); 70 out.println(xmlDocument.print()); 71 out.close(); 72 } 73 } 74 | Popular Tags |