| 1 package org.openbravo.erpCommon.ad_callouts; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 9 import org.openbravo.base.secureApp.HttpSecureAppServlet; 10 import org.openbravo.base.secureApp.VariablesSecureApp; 11 import org.openbravo.data.FieldProvider; 12 import org.openbravo.utils.FormatUtilities; 13 14 public abstract class CalloutHelper extends HttpSecureAppServlet { 15 16 abstract void printPage(HttpServletResponse response, VariablesSecureApp vars, String strTabId, String windowId) throws IOException , ServletException ; 17 18 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException ,ServletException { 19 VariablesSecureApp vars = new VariablesSecureApp(request); 20 if (!vars.commandIn("DEFAULT")) { 21 String strTabId = vars.getStringParameter("inpTabId"); 22 String strWindowId = vars.getStringParameter("inpwindowId"); 23 printPage(response, vars, strTabId, strWindowId); 24 } else 25 pageError(response); 26 } 27 28 String generateArray(FieldProvider[] data) { 29 StringBuffer strArray = new StringBuffer (); 30 if (data==null || data.length==0) 31 strArray.append("null"); 32 else { 33 strArray.append("new Array("); 34 for (int i=0;i<data.length;i++) { 35 strArray.append("\nnew Array(\"").append(data[i].getField("id")).append("\", \"").append(FormatUtilities.replaceJS(data[i].getField("name"))).append("\")"); 36 if (i<data.length-1) strArray.append(", \n"); 37 } 38 strArray.append(")"); 39 } 40 return strArray.toString(); 41 } 42 } 43 | Popular Tags |