Fixed 9335: Implement ComboReloads for the search popup:
authorStefan Hühner <stefan.huehner@openbravo.com>
Mon, 08 Jun 2009 21:55:51 +0200
changeset 3988 eb284f20977d
parent 3987 4566a0142d2e
child 3989 3470ed6f5af6
Fixed 9335: Implement ComboReloads for the search popup:
- add the frameset/hiddenFrame needed for the callouts to the search popup and add servlet code to use it
- enhance ComboTableData class with special case for search popup as its uses a different column name/request name pattern
- enhance generated ComboReloads* code to implement a different pattern as well
- change Search popup servlet to trigger the needed callouts for the ComboReloads
src-wad/src/org/openbravo/wad/ComboReloads.javaxml
src-wad/src/org/openbravo/wad/Fields_data.xsql
src/org/openbravo/erpCommon/ad_callouts/CalloutHelper.java
src/org/openbravo/erpCommon/businessUtility/Buscador.html
src/org/openbravo/erpCommon/businessUtility/Buscador.java
src/org/openbravo/erpCommon/businessUtility/Buscador_FS.html
src/org/openbravo/erpCommon/businessUtility/Buscador_FS.xml
src/org/openbravo/erpCommon/businessUtility/Buscador_data.xsql
src/org/openbravo/erpCommon/utility/ComboTableData.java
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src-wad/src/org/openbravo/wad/ComboReloads.javaxml	Mon Jun 08 18:30:37 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/ComboReloads.javaxml	Mon Jun 08 21:55:51 2009 +0200
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -22,13 +22,15 @@
 <java_TMP>
 package org.openbravo.erpCommon.ad_callouts;
 
-import org.openbravo.base.secureApp.VariablesSecureApp;
-import org.openbravo.xmlEngine.XmlDocument;
-import org.openbravo.erpCommon.utility.*;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.data.Sqlc;
+import org.openbravo.erpCommon.utility.*;
+import org.openbravo.xmlEngine.XmlDocument;
+
 public class ComboReloads<PARAMETER_TMP id="paramTabId">xx</PARAMETER_TMP> extends CalloutHelper {
   private static final long serialVersionUID = 1L;
 
@@ -42,28 +44,51 @@
     ComboTableData comboTableData = null;
     resultado.append("var calloutName='ComboReloads<PARAMETER_TMP id="paramTabId">xx</PARAMETER_TMP>';\n\n");
     resultado.append("var respuesta = new Array(\n");
+
+    // check if call came from searchPopup, if yes remember and adjust command name from popup
+    // column name pattern to normal pattern and set search popup frame name to be used
+    String resultField;
+    String command = vars.getStringParameter("Command", "DEFAULT");
+    boolean calledFromSearch = command.startsWith("inpParam");
+    if (calledFromSearch) {
+      command = command.substring(8);
+      command = Sqlc.TransformaNombreColumna(command);
+      command = "inp" + command;
+      xmlDocument.setParameter("frameName", "mainframe");
+      xmlDocument.setParameter("frameName1", "mainframe");
+    }
+
+    try {
+
     <FIELDS_TMP id="sectionDetail">
-    if (vars.commandIn(<FIELD_TMP id="fieldColumnsName">"xx"</FIELD_TMP>)) {
-      try {
+      if (CalloutHelper.commandInCommandList(command, <FIELD_TMP id="fieldColumnsName">"xx"</FIELD_TMP>)) {
         if (!isFirst) resultado.append(", \n");
         comboTableData = new ComboTableData(vars, this, "<FIELD_TMP id="fieldReference1">17</FIELD_TMP>", "<FIELD_TMP id="fieldColumnName1">name</FIELD_TMP>", "<FIELD_TMP id="fieldReferenceValue1">name</FIELD_TMP>", "<FIELD_TMP id="fieldValidation1">name</FIELD_TMP>", <FIELD_TMP id="fieldOrgCode">xxorgcode</FIELD_TMP>, Utility.getContext(this, vars, "#User_Client", windowId), 0);
-        Utility.fillSQLParameters(this, vars, null, comboTableData, windowId, "");
-        resultado.append("new Array(\"<FIELD_TMP id="fieldColumnChange">xx</FIELD_TMP>\", ");
-        resultado.append(generateArray(comboTableData.select(false), vars.getStringParameter("<FIELD_TMP id="fieldColumnChange">xx</FIELD_TMP>")));
+        if (calledFromSearch) {
+          comboTableData.fillParametersFromSearch("", windowId);
+          resultField = "inpParam<FIELD_TMP id="fieldColumnName1">name</FIELD_TMP>";
+        } else {
+          comboTableData.fillParameters(null, windowId, "");
+          resultField = "<FIELD_TMP id="fieldColumnChange">xx</FIELD_TMP>";
+        }
+        resultado.append("new Array(\"" + resultField + "\", ");
+        resultado.append(generateArray(comboTableData.select(false), vars.getStringParameter(resultField)));
         comboTableData = null;
         resultado.append(")");
         isFirst=false;
-      } catch (ServletException ex) {
-        OBError myError = Utility.translateError(this, vars, vars.getLanguage(), ex.toString());
-        bdErrorHidden(response, myError.getType(), myError.getTitle(), myError.getMessage());
-        return;
-      } catch (Exception ex1) {
-        OBError myError = Utility.translateError(this, vars, vars.getLanguage(), ex1.toString());
-        bdErrorHidden(response, myError.getType(), myError.getTitle(), myError.getMessage());
-        return;
       }
+    </FIELDS_TMP>
+
+    } catch (ServletException ex) {
+      OBError myError = Utility.translateError(this, vars, vars.getLanguage(), ex.toString());
+      bdErrorHidden(response, myError.getType(), myError.getTitle(), myError.getMessage());
+      return;
+    } catch (Exception ex1) {
+      OBError myError = Utility.translateError(this, vars, vars.getLanguage(), ex1.toString());
+      bdErrorHidden(response, myError.getType(), myError.getTitle(), myError.getMessage());
+      return;
     }
-    </FIELDS_TMP>
+
     resultado.append("\n);");
 
     xmlDocument.setParameter("array", resultado.toString());
--- a/src-wad/src/org/openbravo/wad/Fields_data.xsql	Mon Jun 08 18:30:37 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/Fields_data.xsql	Mon Jun 08 21:55:51 2009 +0200
@@ -595,7 +595,7 @@
     <Parameter name="tab"/>
   </SqlMethod>
   <SqlMethod name="selectValidationTab" type="preparedStatement" return="multiple">
-    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
+    <SqlMethodComment>Method need to be synchronized with src/org/openbravo/erpCommon/businessUtility/Buscador_data.xsql::selectValidationTab</SqlMethodComment>
     <Sql>
       <![CDATA[
         SELECT c.ad_column_id as id, c.columnname, t.WHERECLAUSE as whereClause, v.code as referencevalue, c.ad_reference_id as reference,
--- a/src/org/openbravo/erpCommon/ad_callouts/CalloutHelper.java	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/CalloutHelper.java	Mon Jun 08 21:55:51 2009 +0200
@@ -72,4 +72,14 @@
     }
     return strArray.toString();
   }
+
+  static boolean commandInCommandList(String inCommand, String... commandList) {
+    for (String command : commandList) {
+      if (commandList.equals(command)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
 }
--- a/src/org/openbravo/erpCommon/businessUtility/Buscador.html	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador.html	Mon Jun 08 21:55:51 2009 +0200
@@ -244,7 +244,7 @@
                     <button type="button" 
                       id="buttonCancel" 
                       class="ButtonLink" 
-                      onclick="window.close(); return false;" 
+                      onclick="parent.window.close(); return false;" 
                       onfocus="buttonEvent('onfocus', this); window.status='Cancel'; return true;" 
                       onblur="buttonEvent('onblur', this);" 
                       onkeyup="buttonEvent('onkeyup', this);" 
--- a/src/org/openbravo/erpCommon/businessUtility/Buscador.java	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador.java	Mon Jun 08 21:55:51 2009 +0200
@@ -31,6 +31,7 @@
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.data.FieldProvider;
+import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.ComboTableData;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
@@ -52,9 +53,17 @@
     VariablesSecureApp vars = new VariablesSecureApp(request);
 
     if (vars.commandIn("DEFAULT")) {
-      String strTab = vars.getRequiredStringParameter("inpTabId");
-      String strWindow = vars.getRequiredStringParameter("inpWindow");
-      String strWindowId = vars.getStringParameter("inpWindowId");
+      vars.setSessionValue("Buscador.inpTabId", vars.getRequiredStringParameter("inpTabId"));
+      vars.setSessionValue("Buscador.inpWindow", vars.getRequiredStringParameter("inpWindow"));
+      vars.setSessionValue("Buscador.inpWindowId", vars.getStringParameter("inpWindowId"));
+
+      printPageFS(response, vars);
+    }
+
+    if (vars.commandIn("FRAME1")) {
+      String strTab = vars.getSessionValue("Buscador.inpTabId");
+      String strWindow = vars.getSessionValue("Buscador.inpWindow");
+      String strWindowId = vars.getSessionValue("Buscador.inpWindowId");
       String strIsSOTrx = vars.getSessionValue(strWindowId + "|issotrxtab");
       String strShowAudit = Utility.getContext(this, vars, "ShowAudit", strWindowId);
       BuscadorData[] data;
@@ -92,6 +101,18 @@
       pageError(response);
   }
 
+  private void printPageFS(HttpServletResponse response, VariablesSecureApp vars)
+      throws IOException, ServletException {
+
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
+        "org/openbravo/erpCommon/businessUtility/Buscador_FS").createXmlDocument();
+
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close();
+  }
+
   private BuscadorData[] removeParents(BuscadorData[] data, String strTab) throws ServletException {
     String parentColumn = BuscadorData.parentsColumnName(this, strTab);
     if (data == null || data.length == 0)
@@ -324,12 +345,20 @@
       }
     }
     strHtml.append("\n").append(paramsData);
-    strHtml.append("  if (window.opener.selectFilters) window.opener.selectFilters(paramsData);\n");
-    strHtml.append("  else window.opener.submitFormGetParams(\"SEARCH\", \"../" + strWindow + "\""
-        + params.toString() + ");\n");
-    strHtml.append("  window.close();\n");
+    strHtml
+        .append("  if (parent.window.opener.selectFilters) parent.window.opener.selectFilters(paramsData);\n");
+    strHtml.append("  else parent.window.opener.submitFormGetParams(\"SEARCH\", \"../" + strWindow
+        + "\"" + params.toString() + ");\n");
+    strHtml.append("  parent.window.close();\n");
     strHtml.append("  return true;\n");
     strHtml.append("}\n");
+
+    strHtml.append("\nfunction reloadComboReloads(changedField) {\n");
+    strHtml.append("  submitCommandForm(changedField, false, null, '../ad_callouts/ComboReloads"
+        + strTab + ".html', 'hiddenFrame', null, null, true);\n");
+    strHtml.append("  return true;\n");
+    strHtml.append("}\n");
+
     strHtml.append("function onloadFunctions() {\n");
     strHtml.append("  enableLocalShortcuts();\n");
     strHtml.append(strCombo);
@@ -356,6 +385,10 @@
     int randomId4Num3 = 0;
     Random rnd = new Random();
     Vector<Object> vecKeys = new Vector<Object>();
+
+    // get list of fields with comboreloads
+    Vector<String> comboReloadFields = getComboReloadFields(this, strTab);
+
     for (int i = 0; i < fields.length; i++) {
       randomId4Num1 = rnd.nextInt(10000);
       randomId4Num2 = rnd.nextInt(10000);
@@ -379,8 +412,14 @@
         strHtml.append("<select ");
         strHtml.append("name=\"inpParam").append(FormatUtilities.replace(fields[i].columnname))
             .append("\" ");
-        strHtml.append("onchange=\"return true; \" id=\"idParam").append(
-            FormatUtilities.replace(fields[i].columnname)).append("\" ");
+        // attach comboReload call if needed
+        if (isInVector(comboReloadFields, fields[i].columnname)) {
+          strHtml.append("onchange=\"reloadComboReloads(this.name);return true; \" id=\"idParam")
+              .append(FormatUtilities.replace(fields[i].columnname)).append("\" ");
+        } else {
+          strHtml.append("onchange=\"return true; \" id=\"idParam").append(
+              FormatUtilities.replace(fields[i].columnname)).append("\" ");
+        }
         if (Integer.valueOf(fields[i].fieldlength).intValue() < (MAX_TEXTBOX_LENGTH / 4)) {
           strHtml.append("class=\"Combo Combo_OneCell_width\"");
         } else if (Integer.valueOf(fields[i].fieldlength).intValue() < (MAX_TEXTBOX_LENGTH / 2)) {
@@ -395,7 +434,7 @@
               fields[i].columnname, fields[i].referencevalue, fields[i].adValRuleId, Utility
                   .getContext(this, vars, "#AccessibleOrgTree", strWindow), Utility.getContext(
                   this, vars, "#User_Client", strWindow), 0);
-          Utility.fillSQLParameters(this, vars, null, comboTableData, strWindow, fields[i].value);
+          comboTableData.fillParametersFromSearch(strTab, strWindow);
           FieldProvider[] data = comboTableData.select(false);
           comboTableData = null;
           for (int j = 0; j < data.length; j++) {
@@ -885,8 +924,8 @@
     return html.toString();
   }
 
-  private String searchsCommand(BuscadorData efd, boolean fromButton, String tabId, String windowId,
-      String strIsSOTrx) {
+  private String searchsCommand(BuscadorData efd, boolean fromButton, String tabId,
+      String windowId, String strIsSOTrx) {
     StringBuffer params = new StringBuffer();
     StringBuffer html = new StringBuffer();
     String strMethodName = "openSearch";
@@ -1009,8 +1048,66 @@
     return html.toString();
   }
 
+  /**
+   * Gets list of fields which have a comboReload associated to trigger reloads of dependent combos.
+   * Change in logic needs to be synchronized with copy in wad
+   * 
+   * @return List of columnnames of fields with have a comboReload associated
+   */
+  private static Vector<String> getComboReloadFields(ConnectionProvider pool, String strTab)
+      throws ServletException {
+    final BuscadorData[] dataReload = BuscadorData.selectValidationTab(pool, strTab);
+
+    final Vector<String> vecReloads = new Vector<String>();
+    if (dataReload != null && dataReload.length > 0) {
+      for (int z = 0; z < dataReload.length; z++) {
+        String code = dataReload[z].whereclause
+            + ((!dataReload[z].whereclause.equals("") && !dataReload[z].referencevalue.equals("")) ? " AND "
+                : "") + dataReload[z].referencevalue;
+
+        if (code.equals("") && dataReload[z].type.equals("R"))
+          code = "@AD_Org_ID@";
+        getComboReloadText(code, vecReloads, dataReload[z].columnname);
+      }
+    }
+    return vecReloads;
+  }
+
+  private static void getComboReloadText(String token, Vector<String> vecComboReload,
+      String columnname) {
+    int i = token.indexOf("@");
+    while (i != -1) {
+      token = token.substring(i + 1);
+      if (!token.startsWith("SQL")) {
+        i = token.indexOf("@");
+        if (i != -1) {
+          String strAux = token.substring(0, i);
+          token = token.substring(i + 1);
+          getComboReloadTextTranslate(strAux, vecComboReload, columnname);
+        }
+      }
+      i = token.indexOf("@");
+    }
+  }
+
+  private static void getComboReloadTextTranslate(String token, Vector<String> vecComboReload,
+      String columnname) {
+    if (token == null || token.trim().equals(""))
+      return;
+    if (!token.equalsIgnoreCase(columnname))
+      if (!isInVector(vecComboReload, token))
+        vecComboReload.addElement(token);
+  }
+
+  private static boolean isInVector(Vector<String> vec, String field) {
+    for (String aux : vec) {
+      if (aux.equalsIgnoreCase(field))
+        return true;
+    }
+    return false;
+  }
+
   public String getServletInfo() {
-    // FIXME: Should be in English
-    return "Servlet que presenta el buscador";
-  } // end of getServletInfo() method
+    return "Servlet to render the search popup";
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador_FS.html	Mon Jun 08 21:55:51 2009 +0200
@@ -0,0 +1,28 @@
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Search</title>
+<link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" />
+</head>
+<frameset rows="100%,*" frameborder="no" border="0" framespacing="0" cols="*">
+<frame name="mainframe" scrolling="no" noresize="" src="Buscador.html?Command=FRAME1"></frame>
+<frame name="hiddenFrame" scrolling="no" noresize="" src=""></frame></frameset>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador_FS.xml	Mon Jun 08 21:55:51 2009 +0200
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<REPORT>
+	<template file="Buscador_FS.html"/>
+</REPORT>
--- a/src/org/openbravo/erpCommon/businessUtility/Buscador_data.xsql	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador_data.xsql	Mon Jun 08 21:55:51 2009 +0200
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -69,6 +69,13 @@
         <Parameter name="adLanguage"/>
         <Parameter name="adTabId"/>
         <Parameter name="showAudit"/>
+        <Field name="id" value="void"/>
+        <Field name="whereclause" value="void"/>
+        <Field name="nameref" value="void"/>
+        <Field name="defaultvalue" value="void"/>
+        <Field name="isdisplayed" value="void"/>
+        <Field name="istranslated" value="void"/>
+        <Field name="type" value="void"/>
    </SqlMethod>
    
    <SqlMethod name="hasSelectionColumns" type="preparedStatement" return="string">
@@ -202,4 +209,25 @@
       ]]></Sql>
       <Parameter name="ad_reference_id"/>
   </SqlMethod>
+
+  <SqlMethod name="selectValidationTab" type="preparedStatement" return="multiple">
+    <SqlMethodComment>Method need to be synchronized with src-wad/src/org/openbravo/wad/Fields_data.xsql::selectValidationTab</SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT c.ad_column_id as id, c.columnname, t.WHERECLAUSE as whereClause, v.code as referencevalue, c.ad_reference_id as reference,
+        c.ad_reference_value_id as NameRef, c.ad_val_rule_id as defaultvalue, f.isdisplayed, c.istranslated, c.columnname as name,
+        (case when t.whereclause is not null or v.code is not null then 'C' else 'R' end) as type /*Combo reaload or Reference*/ 
+        FROM AD_FIELD f, 
+             AD_COLUMN c left join  AD_VAL_RULE v on c.AD_VAL_RULE_ID = v.AD_VAL_RULE_ID
+                         left join AD_REF_TABLE t on (CASE c.ad_reference_id WHEN '18' THEN c.AD_REFERENCE_VALUE_ID ELSE '0' END) = t.AD_REFERENCE_ID     
+        WHERE f.AD_COLUMN_ID = c.ad_column_id
+        AND f.ad_tab_id = ? 
+        AND (t.whereclause IS NOT NULL
+            OR v.code IS NOT NULL
+            OR c.ad_reference_id in ('19','18','17'))
+      ]]>
+    </Sql>
+    <Parameter name="tab"/>
+  </SqlMethod>
+
 </SqlClass>
--- a/src/org/openbravo/erpCommon/utility/ComboTableData.java	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/utility/ComboTableData.java	Mon Jun 08 21:55:51 2009 +0200
@@ -24,6 +24,8 @@
 import java.util.Hashtable;
 import java.util.Vector;
 
+import javax.servlet.ServletException;
+
 import org.apache.log4j.Logger;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.data.FieldProvider;
@@ -1339,4 +1341,72 @@
     vector.copyInto(objectListData);
     return (objectListData);
   }
+
+  /**
+   * Special fill parameters function to be used from the search popup (servlet).
+   * 
+   * It flags the combo to be used from a search popup changing the logic to get the needed
+   * parameters for a possible where clause: it uses the pattern inpParam<columnName> to get the
+   * values from the request and does not use the preferences for fields to preset a search filter
+   */
+  public void fillParametersFromSearch(String tab, String window) throws ServletException {
+    fillSQLParameters(pool, vars, null, tab, window, "", true);
+  }
+
+  /**
+   * Fill the parameters of the sql with the session values or FieldProvider values. Used in the
+   * combo fields.
+   * 
+   * @param data
+   *          optional FieldProvider which can be used to get the needed parameter values from. If
+   *          the FieldProvider has a filed named after a parameter, then its value will be used if
+   *          the value could not be already obtained from the request parameters.
+   * @param window
+   *          Window id.
+   * @param actual_value
+   *          actual value for the combo.
+   * @throws ServletException
+   */
+  public void fillParameters(FieldProvider data, String window, String actual_value)
+      throws ServletException {
+    fillSQLParameters(pool, vars, data, "", window, actual_value, false);
+  }
+
+  /**
+   * Fill the parameters of the sql with the session values or FieldProvider values. Used in the
+   * combo fields.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param data
+   *          FieldProvider with the columns values.
+   * @param window
+   *          Window id.
+   * @param actual_value
+   *          actual value for the combo.
+   * @throws ServletException
+   */
+  void fillSQLParameters(ConnectionProvider conn, VariablesSecureApp vars, FieldProvider data,
+      String tab, String window, String actual_value, boolean fromSearch) throws ServletException {
+    final Vector<String> vAux = getParameters();
+    if (vAux != null && vAux.size() > 0) {
+      if (log4j.isDebugEnabled())
+        log4j.debug("Combo Parameters: " + vAux.size());
+      for (int i = 0; i < vAux.size(); i++) {
+        final String strAux = vAux.elementAt(i);
+        try {
+          final String value = Utility.parseParameterValue(conn, vars, data, strAux, tab, window,
+              actual_value, fromSearch);
+          if (log4j.isDebugEnabled())
+            log4j.debug("Combo Parameter: " + strAux + " - Value: " + value);
+          setParameter(strAux, value);
+        } catch (final Exception ex) {
+          throw new ServletException(ex);
+        }
+      }
+    }
+  }
+
 }
--- a/src/org/openbravo/erpCommon/utility/Utility.java	Mon Jun 08 18:30:37 2009 +0200
+++ b/src/org/openbravo/erpCommon/utility/Utility.java	Mon Jun 08 21:55:51 2009 +0200
@@ -1153,26 +1153,13 @@
    * @param actual_value
    *          actual value for the combo.
    * @throws ServletException
+   * @see org.openbravo.erpCommon.utility.ComboTableData#fillParameters(FieldProvider, String,
+   *      String)
    */
   public static void fillSQLParameters(ConnectionProvider conn, VariablesSecureApp vars,
       FieldProvider data, ComboTableData cmb, String window, String actual_value)
       throws ServletException {
-    final Vector<String> vAux = cmb.getParameters();
-    if (vAux != null && vAux.size() > 0) {
-      if (log4j.isDebugEnabled())
-        log4j.debug("Combo Parameters: " + vAux.size());
-      for (int i = 0; i < vAux.size(); i++) {
-        final String strAux = vAux.elementAt(i);
-        try {
-          final String value = parseParameterValue(conn, vars, data, strAux, window, actual_value);
-          if (log4j.isDebugEnabled())
-            log4j.debug("Combo Parameter: " + strAux + " - Value: " + value);
-          cmb.setParameter(strAux, value);
-        } catch (final Exception ex) {
-          throw new ServletException(ex);
-        }
-      }
-    }
+    cmb.fillSQLParameters(conn, vars, data, "", window, actual_value, false);
   }
 
   /**
@@ -1200,7 +1187,7 @@
       for (int i = 0; i < vAux.size(); i++) {
         final String strAux = vAux.elementAt(i);
         try {
-          final String value = parseParameterValue(conn, vars, data, strAux, window, "");
+          final String value = parseParameterValue(conn, vars, data, strAux, "", window, "", false);
           if (log4j.isDebugEnabled())
             log4j.debug("Combo Parameter: " + strAux + " - Value: " + value);
           cmb.setParameter(strAux, value);
@@ -1215,6 +1202,9 @@
    * Auxiliar method, used by fillSQLParameters and fillTableSQLParameters to get the values for
    * each parameter.
    * 
+   * Deprecated as only internal utility function for ComboTableData and TableSQLData code, should
+   * never be used directly by other code.
+   * 
    * @param conn
    *          Handler for the database connection.
    * @param vars
@@ -1230,6 +1220,7 @@
    * @return String with the parsed parameter.
    * @throws Exception
    */
+  @Deprecated
   public static String parseParameterValue(ConnectionProvider conn, VariablesSecureApp vars,
       FieldProvider data, String name, String window, String actual_value) throws Exception {
     String strAux = null;
@@ -1249,6 +1240,60 @@
   }
 
   /**
+   * Auxiliary method, used by fillSQLParameters and fillTableSQLParameters to get the values for
+   * each parameter.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param data
+   *          FieldProvider with the columns values.
+   * @param name
+   *          Name of the parameter.
+   * @param window
+   *          Window id.
+   * @param actual_value
+   *          Actual value.
+   * @param fromSearch
+   *          If the combo is used from the search popup (servlet). If true, then the pattern for
+   *          obtaining the parameter values if changed to conform with the search popup naming.
+   * @return String with the parsed parameter.
+   * @throws Exception
+   */
+  static String parseParameterValue(ConnectionProvider conn, VariablesSecureApp vars,
+      FieldProvider data, String name, String tab, String window, String actual_value,
+      boolean fromSearch) throws Exception {
+    String strAux = null;
+    if (name.equalsIgnoreCase("@ACTUAL_VALUE@"))
+      return actual_value;
+    if (data != null)
+      strAux = data.getField(name);
+    if (strAux == null) {
+      if (fromSearch) {
+        // search popup has different incoming parameter name pattern
+        // also preferences (getContext) should not be used for combos in the search popup,
+        strAux = vars.getStringParameter("inpParam" + name);
+        log4j.debug("parseParameterValues - getStringParameter(inpParam" + name + "): " + strAux);
+        // but as search popup 'remembers' old values via the session the read from there needs
+        // to be made here, as we disabled getContext (where it was before)
+        if (strAux == null || strAux.equals(""))
+          strAux = vars.getSessionValue(tab + "|param" + name);
+        // strAux = vars.getSessionValue(window + "|" + name);
+        // strAux = Utility.getContext(conn, vars, name, window);
+      } else {
+        strAux = vars.getStringParameter("inp" + Sqlc.TransformaNombreColumna(name));
+        if (log4j.isDebugEnabled())
+          log4j.debug("parseParameterValues - getStringParameter(inp"
+              + Sqlc.TransformaNombreColumna(name) + "): " + strAux);
+        if (strAux == null || strAux.equals(""))
+          strAux = Utility.getContext(conn, vars, name, window);
+      }
+    }
+    return strAux;
+  }
+
+  /**
    * Gets the Message for the instance of the processes.
    * 
    * @param conn