1 19 package org.openbravo.erpCommon.info; 20 21 import org.openbravo.base.secureApp.*; 22 import org.openbravo.xmlEngine.XmlDocument; 23 import org.openbravo.erpCommon.utility.Utility; 24 import java.io.*; 25 import javax.servlet.*; 26 import javax.servlet.http.*; 27 28 29 30 public class ImageInfo extends HttpSecureAppServlet { 31 32 33 public void init (ServletConfig config) { 34 super.init(config); 35 boolHist = false; 36 } 37 38 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 39 VariablesSecureApp vars = new VariablesSecureApp(request); 40 41 if (vars.commandIn("DEFAULT")) { 42 String strWindowId = vars.getStringParameter("WindowID"); 43 String strKey = vars.getStringParameter("inpNameValue"); 44 String strNameValue = ImageInfoData.selectName(this, strKey); 45 String strBpartner = Utility.getContext(this, vars, "isSOTrx", strWindowId); 46 if (!strNameValue.equals("")) vars.setSessionValue("ImageInfo.name", strNameValue + "%"); 47 printPageFS(response, vars); 48 } else if (vars.commandIn("FRAME1")) { 49 String strNameValue = vars.getGlobalVariable("inpName", "ImageInfo.name", ""); 50 printPageFrame1(response, vars, strNameValue); 51 } else if (vars.commandIn("FRAME2")) { 52 String strName = vars.getGlobalVariable("inpName", "ImageInfo.name", ""); 53 String strURL = vars.getStringParameter("inpURL"); 54 printPageFrame2(response, vars, strName, strURL); 55 } else if (vars.commandIn("FIND")) { 56 String strName = vars.getRequestGlobalVariable("inpName", "ImageInfo.name"); 57 String strURL = vars.getStringParameter("inpURL"); 58 59 vars.setSessionValue("ImageInfo.initRecordNumber", "0"); 60 61 printPageFrame2(response, vars, strName, strURL); 62 } else if (vars.commandIn("FRAME3")) { 63 printPageFrame3(response, vars); 64 } else if (vars.commandIn("PREVIOUS")) { 65 String strInitRecord = vars.getSessionValue("ImageInfo.initRecordNumber"); 66 String strRecordRange = Utility.getContext(this, vars, "#RecordRangeInfo", "ImageInfo"); 67 int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange); 68 if (strInitRecord.equals("") || strInitRecord.equals("0")) vars.setSessionValue("ImageInfo.initRecordNumber", "0"); 69 else { 70 int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord)); 71 initRecord -= intRecordRange; 72 strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord)); 73 vars.setSessionValue("ImageInfo.initRecordNumber", strInitRecord); 74 } 75 76 response.sendRedirect(strDireccion + request.getServletPath() + "?Command=FRAME2"); 77 } else if (vars.commandIn("NEXT")) { 78 String strInitRecord = vars.getSessionValue("ImageInfo.initRecordNumber"); 79 String strRecordRange = Utility.getContext(this, vars, "#RecordRangeInfo", "ImageInfo"); 80 int intRecordRange = strRecordRange.equals("")?0:Integer.parseInt(strRecordRange); 81 int initRecord = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord)); 82 if (initRecord==0) initRecord=1; 83 initRecord += intRecordRange; 84 strInitRecord = ((initRecord<0)?"0":Integer.toString(initRecord)); 85 vars.setSessionValue("ImageInfo.initRecordNumber", strInitRecord); 86 87 response.sendRedirect(strDireccion + request.getServletPath() + "?Command=FRAME2"); 88 } else pageError(response); 89 } 90 91 void printPageFS(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException { 92 if (log4j.isDebugEnabled()) log4j.debug("Output: Image seeker Frame Set"); 93 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/ImageInfo_FS").createXmlDocument(); 94 95 response.setContentType("text/html; charset=UTF-8"); 96 PrintWriter out = response.getWriter(); 97 out.println(xmlDocument.print()); 98 out.close(); 99 } 100 101 void printPageFrame1(HttpServletResponse response, VariablesSecureApp vars, String strNameValue) throws IOException, ServletException { 102 if (log4j.isDebugEnabled()) log4j.debug("Output: Frame 1 of the image seeker"); 103 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/ImageInfo_F1").createXmlDocument(); 104 if (strNameValue.equals("")) { 105 xmlDocument.setParameter("name", "%"); 106 } else { 107 xmlDocument.setParameter("name", strNameValue); 108 } 109 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 110 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 111 response.setContentType("text/html; charset=UTF-8"); 112 PrintWriter out = response.getWriter(); 113 out.println(xmlDocument.print()); 114 out.close(); 115 } 116 117 void printPageFrame2(HttpServletResponse response, VariablesSecureApp vars, String strName, String strURL) throws IOException, ServletException { 118 if (log4j.isDebugEnabled()) log4j.debug("Output: Frame 2 of the image seeker"); 119 XmlDocument xmlDocument; 120 121 String strRecordRange = Utility.getContext(this, vars, "#RecordRangeInfo", "ImageInfo"); 122 int intRecordRange = (strRecordRange.equals("")?0:Integer.parseInt(strRecordRange)); 123 String strInitRecord = vars.getSessionValue("ImageInfo.initRecordNumber"); 124 int initRecordNumber = (strInitRecord.equals("")?0:Integer.parseInt(strInitRecord)); 125 126 if (strName.equals("") && strURL.equals("")) { 127 String [] discard = {"sectionDetail", "hasPrevious", "hasNext"}; 128 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/ImageInfo_F2", discard).createXmlDocument(); 129 xmlDocument.setData("structure1", ImageInfoData.set()); 130 } else { 131 String [] discard = {"withoutPrevious", "withoutNext"}; 132 ImageInfoData[] data = ImageInfoData.select(this, Utility.getContext(this, vars, "#User_Client", "ImageInfo"), Utility.getContext(this, vars, "#User_Org", "ImageInfo"), strName, strURL, initRecordNumber, intRecordRange); 133 if (data==null || data.length==0 || initRecordNumber<=1) discard[0] = new String ("hasPrevious"); 134 if (data==null || data.length==0 || data.length<intRecordRange) discard[1] = new String ("hasNext"); 135 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/ImageInfo_F2", discard).createXmlDocument(); 136 xmlDocument.setData("structure1", data); 137 } 138 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 139 response.setContentType("text/html; charset=UTF-8"); 140 PrintWriter out = response.getWriter(); 141 out.println(xmlDocument.print()); 142 out.close(); 143 } 144 145 void printPageFrame3(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException { 146 if (log4j.isDebugEnabled()) log4j.debug("Output: Frame 3 of the image seeker"); 147 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/info/ImageInfo_F3").createXmlDocument(); 148 149 response.setContentType("text/html; charset=UTF-8"); 150 PrintWriter out = response.getWriter(); 151 out.println(xmlDocument.print()); 152 out.close(); 153 } 154 155 public String getServletInfo() { 156 return "Servlet that presents que image seeker"; 157 } } 159 | Popular Tags |