issue 9495: Add combo reloads to menu PL action buttons
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 18 Jun 2009 11:18:06 +0200
changeset 4039 1497f4e7671a
parent 4032 73846024f942
child 4040 959292373f4f
issue 9495: Add combo reloads to menu PL action buttons
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
src-wad/src/org/openbravo/wad/ActionButton_Responser.javaxml
src-wad/src/org/openbravo/wad/ComboReloads.xml
src-wad/src/org/openbravo/wad/ComboReloadsProcess.javaxml
src-wad/src/org/openbravo/wad/ComboReloadsProcess.xml
src-wad/src/org/openbravo/wad/ComboReloadsProcessHelper.javaxml
src-wad/src/org/openbravo/wad/ComboReloadsProcessHelper.xml
src-wad/src/org/openbravo/wad/Fields_data.xsql
src-wad/src/org/openbravo/wad/Wad.java
src-wad/src/org/openbravo/wad/WadActionButton.java
src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefault.html
src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefaultFrames.html
src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefaultFrames.xml
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -17264,6 +17264,19 @@
 <!--69EB0238E9FE452280BCCE231E71D1E9-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--69EB0238E9FE452280BCCE231E71D1E9--></AD_MODEL_OBJECT>
 
+<!--80E9860340904A759C0BB5DF8FDFCA0F--><AD_MODEL_OBJECT>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <AD_MODEL_OBJECT_ID><![CDATA[80E9860340904A759C0BB5DF8FDFCA0F]]></AD_MODEL_OBJECT_ID>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <ACTION><![CDATA[P]]></ACTION>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_callouts.ComboReloadsProcessHelper]]></CLASSNAME>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--80E9860340904A759C0BB5DF8FDFCA0F-->  <NAME><![CDATA[ComboReloadsProcessHelper]]></NAME>
+<!--80E9860340904A759C0BB5DF8FDFCA0F--></AD_MODEL_OBJECT>
+
 <!--88420DFF1C6D48A18800FB91A91362AA--><AD_MODEL_OBJECT>
 <!--88420DFF1C6D48A18800FB91A91362AA-->  <AD_MODEL_OBJECT_ID><![CDATA[88420DFF1C6D48A18800FB91A91362AA]]></AD_MODEL_OBJECT_ID>
 <!--88420DFF1C6D48A18800FB91A91362AA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -25300,6 +25300,16 @@
 <!--18765831DAEC41E3A2C2B5B3AF41F11D-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--18765831DAEC41E3A2C2B5B3AF41F11D--></AD_MODEL_OBJECT_MAPPING>
 
+<!--20C37AE558EE4F1E93C189F63AFD7483--><AD_MODEL_OBJECT_MAPPING>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[20C37AE558EE4F1E93C189F63AFD7483]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <AD_MODEL_OBJECT_ID><![CDATA[80E9860340904A759C0BB5DF8FDFCA0F]]></AD_MODEL_OBJECT_ID>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <MAPPINGNAME><![CDATA[/ad_callouts/ComboReloadsProcessHelper.html]]></MAPPINGNAME>
+<!--20C37AE558EE4F1E93C189F63AFD7483-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--20C37AE558EE4F1E93C189F63AFD7483--></AD_MODEL_OBJECT_MAPPING>
+
 <!--2928B102BC6411DDA5BD001A4D8085A3--><AD_MODEL_OBJECT_MAPPING>
 <!--2928B102BC6411DDA5BD001A4D8085A3-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[2928B102BC6411DDA5BD001A4D8085A3]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--2928B102BC6411DDA5BD001A4D8085A3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-wad/src/org/openbravo/wad/ActionButton_Responser.javaxml	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/ActionButton_Responser.javaxml	Thu Jun 18 11:18:06 2009 +0200
@@ -54,7 +54,10 @@
       strProcessId = vars.getRequiredStringParameter("inpadProcessId");
     else if (command.startsWith("BUTTON"))
       strProcessId = command.substring("BUTTON".length());
-    else if (command.startsWith("SAVE_BUTTONActionButton"))
+    else if (command.startsWith("FRAMES")) {
+      strProcessId = command.substring("FRAMES".length());
+      printPageFrames(response, vars, strProcessId);
+    } else if (command.startsWith("SAVE_BUTTONActionButton"))
       strProcessId = command.substring("SAVE_BUTTONActionButton".length());
    
     if (!vars.commandIn("DEFAULT") &amp;&amp; !hasGeneralAccess(vars, "P", strProcessId)) {
@@ -94,6 +97,18 @@
     out.println(xmlDocument.print());
     out.close();
   }
+  
+  void printPageFrames(HttpServletResponse response, VariablesSecureApp vars, String strProcessId) throws IOException, ServletException {
+    log4j.debug("Output: Default");
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/ActionButtonDefaultFrames").createXmlDocument();
+    xmlDocument.setParameter("processId", strProcessId);
+    xmlDocument.setParameter("trlFormType", "PROCESS");
+    xmlDocument.setParameter("language", "defaultLang = \"" + vars.getLanguage() + "\";\n");
+    out.println(xmlDocument.print());
+    out.close();
+  }
 
 <FIELDS_TMP id="sectionActionButtons2">    void printPageButton<FIELD_TMP id="ProcessID2">xx</FIELD_TMP>(HttpServletResponse response, VariablesSecureApp vars, String strProcessId<FIELD_TMP id="FieldsLoadName2">, strFields</FIELD_TMP>)
     throws IOException, ServletException {
--- a/src-wad/src/org/openbravo/wad/ComboReloads.xml	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/ComboReloads.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -21,9 +21,6 @@
 
 
 <REPORT>
-<template file="ComboReloads.javaxml" />
-<PARAMETER id="paramTabId" name="tabId"/>
-
 <structure name="structure1">
   <FIELD id="fieldColumnsName">whereclause</FIELD>
   <FIELD id="fieldColumnChange">columnname</FIELD>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/ComboReloadsProcess.javaxml	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,33 @@
+<?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):  ______________________________________.
+ ************************************************************************
+-->
+    <FIELDS_TMP id="sectionDetail">
+      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);
+        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;
+      }
+    </FIELDS_TMP>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/ComboReloadsProcess.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,44 @@
+<?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="ComboReloadsProcess.javaxml" />
+<PARAMETER id="paramTabId" name="tabId"/>
+
+<structure name="structure1">
+  <FIELD id="fieldColumnsName">whereclause</FIELD>
+  <FIELD id="fieldColumnChange">columnname</FIELD>
+  <FIELD id="fieldTableName1">tablename</FIELD>
+  <FIELD id="fieldTableName2">tablenametrl</FIELD>
+  <FIELD id="fieldMethod1">htmltext</FIELD>
+  <FIELD id="fieldMethod2">htmltexttrl</FIELD>
+  <FIELD id="fieldSelectFields1">xmltext</FIELD>
+  <FIELD id="fieldOrgCode">orgcode</FIELD>
+  <FIELD id="fieldSelectFields2">xmltexttrl</FIELD>
+  <FIELD id="fieldReference1">reference</FIELD>
+  <FIELD id="fieldColumnName1">name</FIELD>
+  <FIELD id="fieldReferenceValue1">nameref</FIELD>
+  <FIELD id="fieldValidation1">defaultvalue</FIELD>
+  <SECTION id="sectionDetail"/>
+</structure>
+
+</REPORT>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/ComboReloadsProcessHelper.javaxml	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,82 @@
+<?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):  ______________________________________.
+ ************************************************************************
+-->
+
+
+<java_TMP>
+package org.openbravo.erpCommon.ad_callouts;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.erpCommon.utility.ComboTableData;
+import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.xmlEngine.XmlDocument;
+
+
+public class ComboReloadsProcessHelper extends CalloutHelper {
+  private static final long serialVersionUID = 1L;
+
+  void printPage(HttpServletResponse response, VariablesSecureApp vars, String strTabId, String windowId) throws IOException, ServletException {
+   String strProcessId = vars.getStringParameter("inpadProcessId");
+   <FIELDS_TMP id="sectionDetail">
+     if (strProcessId.equals("<FIELD_TMP id="fieldProcessId">xx</FIELD_TMP>")) {
+        String resultField;
+        String command = vars.getStringParameter("Command", "DEFAULT");
+        XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
+        
+        StringBuffer resultado = new StringBuffer();
+        boolean isFirst=true;
+        ComboTableData comboTableData = null;
+        resultado.append("var calloutName='ComboReloads<FIELD_TMP id="fieldProcessId">xx</FIELD_TMP>';\n\n");
+        resultado.append("var respuesta = new Array(\n");
+    
+        try {
+          <PARAMETER_TMP id="reportComboReloadsProcess"></PARAMETER_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;
+        }
+    
+        resultado.append("\n);");
+    
+        xmlDocument.setParameter("array", resultado.toString());
+        xmlDocument.setParameter("frameName", "mainframe");
+        xmlDocument.setParameter("frameName1", "mainframe");
+        response.setContentType("text/html; charset=UTF-8");
+        PrintWriter out = response.getWriter();
+        out.println(xmlDocument.print());
+        out.close();
+ 
+       return;
+     }
+    </FIELDS_TMP>
+    
+    pageError(response);
+  }
+}
+</java_TMP>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/ComboReloadsProcessHelper.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,33 @@
+<?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="ComboReloadsProcessHelper.javaxml" />
+<PARAMETER id="paramTabId" name="tabId"/>
+
+<structure name="structure1">
+  <FIELD id="fieldProcessId">id</FIELD>
+  <SECTION id="sectionDetail"/>
+  <SUBREPORT id="reportComboReloadsProcess" name="reportComboReloadsProcess" report="org/openbravo/wad/ComboReloadsProcess" />
+</structure>
+
+</REPORT>
--- a/src-wad/src/org/openbravo/wad/Fields_data.xsql	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/Fields_data.xsql	Thu Jun 18 11:18:06 2009 +0200
@@ -613,6 +613,39 @@
     </Sql>
     <Parameter name="tab"/>
   </SqlMethod>
+  
+  <SqlMethod name="selectProcessesWithReloads" type="preparedStatement" return="multiple">
+    <SqlMethodComment>Obtains all processes that might require combo reload</SqlMethodComment>
+    <Sql>
+      <![CDATA[
+         SELECT distinct c.AD_PROCESS_id as id
+        FROM AD_PROCESS_PARA 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 (t.whereclause IS NOT NULL
+            OR v.code IS NOT NULL
+            OR c.ad_reference_id in ('19','18','17'))
+      ]]>
+    </Sql>
+  </SqlMethod>
+  
+  <SqlMethod name="selectValidationProcess" type="preparedStatement" return="multiple">
+    <SqlMethodComment>Obtains all param for processes that might require combo reload</SqlMethodComment>
+    <Sql>
+      <![CDATA[
+         SELECT c.AD_PROCESS_PARA_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,  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_PROCESS_PARA 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 (t.whereclause IS NOT NULL
+            OR v.code IS NOT NULL
+            OR c.ad_reference_id in ('19','18','17'))
+         AND c.AD_Process_ID = ?
+      ]]>
+    </Sql>
+    <Parameter name="processId"/>
+  </SqlMethod>
+  
   <SqlMethod name="selectColumnTable" type="preparedStatement" return="multiple">
     <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
     <Sql>
@@ -632,6 +665,24 @@
     <Parameter name="adTabId"/>
     <Parameter name="adColumnId"/>
   </SqlMethod>
+  
+  <SqlMethod name="selectColumnTableProcess" type="preparedStatement" return="multiple">
+    <Sql>
+      SELECT ColumnName As Name, 'x' as xmltext, ad_reference_value_id as referencevalue, 
+      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname,
+      ad_ref_table.WHERECLAUSE, ad_table.tablename, 'TableList' as tablenametrl, ad_table.name as nameref, 
+      '18' as reference, 'Y' as required, 'N' istranslated 
+      FROM ad_process_para p left join ad_val_rule on p.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID, 
+           ad_ref_table, 
+           ad_table 
+      WHERE ad_ref_table.ad_table_id = ad_table.ad_table_id 
+      AND p.AD_REFERENCE_VALUE_ID = ad_ref_table.AD_REFERENCE_ID  
+      AND p.ad_process_para_id = ?
+      AND p.ad_reference_id = '18'
+    </Sql>
+    <Parameter name="processParaId"/>
+  </SqlMethod>
+  
   <SqlMethod name="selectColumnTableDir" type="preparedStatement" return="multiple">
     <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
     <Sql>
@@ -649,6 +700,19 @@
     <Parameter name="adTabId"/>
     <Parameter name="adColumnId"/>
   </SqlMethod>
+  
+  <SqlMethod name="selectColumnTableDirProcess" type="preparedStatement" return="multiple">
+    <Sql>
+      SELECT ColumnName As Name, 'x' as xmltext, ColumnName as referencevalue, 
+      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname,  
+      'TableDir' as tablenametrl, '' as WHERECLAUSE, '19' as reference, 'N' as istranslated 
+      FROM ad_process_para p left join ad_val_rule on p.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID
+      WHERE p.ad_process_para_id = ?
+      AND ad_reference_id = '19'
+    </Sql>
+    <Parameter name="processParaId"/>
+  </SqlMethod>
+  
   <SqlMethod name="columnName" type="preparedStatement" return="String" default="">
     <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
     <Sql>
--- a/src-wad/src/org/openbravo/wad/Wad.java	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/Wad.java	Thu Jun 18 11:18:06 2009 +0200
@@ -355,10 +355,12 @@
       // If generateTabs parameter is true, the action buttons must be
       // generated
       if (generateTabs) {
-        if (!quick || ProcessRelationData.generateActionButton(wad.pool))
+        if (!quick || ProcessRelationData.generateActionButton(wad.pool)) {
+          wad.processProcessComboReloads(fileFinReloads);
           wad.processActionButton(fileReference);
-        else
+        } else {
           log4j.info("No changes in ActionButton_data.xml");
+        }
         if (!quick || FieldsData.buildActionButton(wad.pool)) {
           wad.processActionButtonXml(fileActionButton);
           wad.processActionButtonHtml(fileActionButton);
@@ -497,9 +499,28 @@
       if (fd != null) {
         for (int i = 0; i < fd.length; i++) {
           final Vector<Object> vecFields = new Vector<Object>();
+
+          // calculate fields that need combo reload
+          final FieldsData[] dataReload = FieldsData.selectValidationTab(pool, fd[i].reference);
+
+          final Vector<Object> vecReloads = new Vector<Object>();
+          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@";
+              WadUtility.getComboReloadText(code, vecFields, null, vecReloads, "",
+                  dataReload[z].columnname);
+            }
+          }
+
+          // build the html template
           WadActionButton.buildHtml(pool, xmlEngine, fileReference, fd[i], vecFields,
               MAX_TEXTBOX_LENGTH, MAX_SIZE_EDITION_1_COLUMNS, "", false, calendarDescription,
-              clockDescription, calculatorDescription, jsDateFormat);
+              clockDescription, calculatorDescription, jsDateFormat, vecFields);
         }
       }
     } catch (final ServletException e) {
@@ -590,9 +611,28 @@
       if (fd != null) {
         for (int i = 0; i < fd.length; i++) {
           final Vector<Object> vecFields = new Vector<Object>();
+
+          // calculate fields that need combo reload
+          final FieldsData[] dataReload = FieldsData.selectValidationTab(pool, fd[i].reference);
+
+          final Vector<Object> vecReloads = new Vector<Object>();
+          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@";
+              WadUtility.getComboReloadText(code, vecFields, null, vecReloads, "",
+                  dataReload[z].columnname);
+            }
+          }
+
+          // build the html template
           WadActionButton.buildHtml(pool, xmlEngine, fileReference, fd[i], vecFields,
               MAX_TEXTBOX_LENGTH, MAX_SIZE_EDITION_1_COLUMNS, "", true, calendarDescription,
-              clockDescription, calculatorDescription, jsDateFormat);
+              clockDescription, calculatorDescription, jsDateFormat, vecFields);
         }
       }
     } catch (final ServletException e) {
@@ -3291,6 +3331,163 @@
   }
 
   /**
+   * Generates combo reloads for all action buttons
+   * 
+   * @param fileDir
+   *          Directory to save the generated java
+   * @throws ServletException
+   * @throws IOException
+   */
+  private void processProcessComboReloads(File fileDir) throws ServletException, IOException {
+    log4j.info("Processig combo reloads for action buttons ");
+    Vector<FieldsData> generatedProcesses = new Vector<FieldsData>();
+    Vector<FieldsData[]> processCode = new Vector<FieldsData[]>();
+    FieldsData[] processes = FieldsData.selectProcessesWithReloads(pool);
+
+    for (FieldsData process : processes) {
+
+      String processId = process.id;
+
+      final FieldsData[] data = FieldsData.selectValidationProcess(pool, processId);
+      if (data == null || data.length == 0)
+        return;
+
+      final Vector<Object> vecReloads = new Vector<Object>();
+      final Vector<Object> vecTotal = new Vector<Object>();
+
+      FieldsData[] result = null;
+
+      for (int i = 0; i < data.length; i++) {
+
+        final String code = data[i].whereclause
+            + ((!data[i].whereclause.equals("") && !data[i].referencevalue.equals("")) ? " AND "
+                : "") + data[i].referencevalue;
+        data[i].columnname = "inp" + Sqlc.TransformaNombreColumna(data[i].columnname);
+        data[i].whereclause = WadUtility.getComboReloadText(code, null, null, vecReloads, "inp");
+        if (data[i].whereclause.equals("") && data[i].type.equals("R"))
+          data[i].whereclause = "\"inpadOrgId\"";
+        if (data[i].reference.equals("17") && data[i].whereclause.equals(""))
+          data[i].whereclause = "\"inp" + data[i].columnname + "\"";
+        if (!data[i].whereclause.equals("")
+            && (data[i].reference.equals("17") || data[i].reference.equals("18") || data[i].reference
+                .equals("19"))) {
+
+          data[i].orgcode = "Utility.getReferenceableOrg(vars, vars.getStringParameter(\"inpadOrgId\"))";
+
+          if (data[i].reference.equals("17")) { // List
+            data[i].tablename = "List";
+            data[i].tablenametrl = "List";
+            data[i].htmltext = "select";
+            data[i].htmltexttrl = "selectLanguage";
+            data[i].xmltext = ", \"" + data[i].nameref + "\"";
+            data[i].xmltexttrl = data[i].xmltext + ", vars.getLanguage()";
+            data[i].xmltext += ", \"\"";
+            data[i].xmltexttrl += ", \"\"";
+          } else if (data[i].reference.equals("18")) { // Table
+            final FieldsData[] tables = FieldsData.selectColumnTableProcess(pool, data[i].id);
+            if (tables == null || tables.length == 0)
+              throw new ServletException("No se ha encontrado la Table para la columnId: "
+                  + data[i].id);
+            final StringBuffer where = new StringBuffer();
+            final Vector<Object> vecFields1 = new Vector<Object>();
+            final Vector<Object> vecTables = new Vector<Object>();
+            final Vector<Object> vecWhere = new Vector<Object>();
+            final Vector<Object> vecParameters = new Vector<Object>();
+            final Vector<Object> vecTableParameters = new Vector<Object>();
+            WadUtility.columnIdentifier(pool, tables[0].tablename, true, tables[0], 0, 0, true,
+                vecFields1, vecTables, vecWhere, vecParameters, vecTableParameters, sqlDateFormat);
+            where.append(tables[0].whereclause);
+            data[i].tablename = "TableList";
+            data[i].htmltext = "select" + tables[0].referencevalue;
+            if (!tables[0].columnname.equals("")) {
+              data[i].htmltext += "_" + tables[0].columnname;
+              data[i].tablename = "TableListVal";
+              if (!where.toString().equals(""))
+                where.append(" AND ");
+              where.append(tables[0].defaultvalue);
+            }
+            data[i].tablenametrl = data[i].tablename + "Trl";
+            data[i].htmltexttrl = data[i].htmltext;
+            data[i].xmltext = "";
+            if (vecTableParameters.size() > 0) {
+              data[i].xmltext = ", vars.getLanguage()";
+            }
+            data[i].xmltext += ", Utility.getContext(this, vars, \"#User_Org\", windowId), Utility.getContext(this, vars, \"#User_Client\", windowId)";
+            data[i].xmltext += WadUtility.getWadComboReloadContext(where.toString(), "N");
+            data[i].xmltexttrl = data[i].xmltext;
+            if (vecParameters.size() > 0 && vecTableParameters.size() == 0) {
+              data[i].xmltext += ", vars.getLanguage()";
+              data[i].xmltexttrl += ", vars.getLanguage()";
+            }
+            data[i].xmltext += ", \"\"";
+            data[i].xmltexttrl += ", \"\"";
+          } else if (data[i].reference.equals("19")) { // TableDir
+            final FieldsData[] tableDir = FieldsData.selectColumnTableDirProcess(pool, data[i].id);
+            if (tableDir == null || tableDir.length == 0)
+              throw new ServletException("No se ha encontrado la TableDir para la columnId: "
+                  + data[i].id);
+            data[i].tablename = "TableDir";
+            data[i].htmltext = "select" + tableDir[0].referencevalue;
+            final String table_Name = tableDir[0].name.substring(0, tableDir[0].name.length() - 3);
+            final Vector<Object> vecFields1 = new Vector<Object>();
+            final Vector<Object> vecTables = new Vector<Object>();
+            final Vector<Object> vecWhere = new Vector<Object>();
+            final Vector<Object> vecParameters = new Vector<Object>();
+            final Vector<Object> vecTableParameters = new Vector<Object>();
+            WadUtility.columnIdentifier(pool, table_Name, true, tableDir[0], 0, 0, true,
+                vecFields1, vecTables, vecWhere, vecParameters, vecTableParameters, sqlDateFormat);
+            data[i].xmltext = "";
+            if (vecTableParameters.size() > 0) {
+              data[i].xmltext = ", vars.getLanguage()";
+            }
+            data[i].xmltext += ", Utility.getContext(this, vars, \"#User_Org\", windowId), Utility.getContext(this, vars, \"#User_Client\", windowId)";
+            if (!tableDir[0].columnname.equals("")) {
+              data[i].htmltext += "_" + tableDir[0].columnname;
+              data[i].tablename = "TableDirVal";
+              data[i].xmltext += WadUtility.getWadComboReloadContext(tableDir[0].defaultvalue, "N");
+            } else {
+              data[i].tablename = "TableDir";
+            }
+            data[i].tablenametrl = data[i].tablename + "Trl";
+            data[i].htmltexttrl = data[i].htmltext;
+            data[i].xmltexttrl = data[i].xmltext;
+            if (vecParameters.size() > 0 && vecTableParameters.size() == 0) {
+              data[i].xmltext += ", vars.getLanguage()";
+              data[i].xmltexttrl += ", vars.getLanguage()";
+            }
+            data[i].xmltext += ", \"\"";
+            data[i].xmltexttrl += ", \"\"";
+          }
+          vecTotal.addElement(data[i]);
+        }
+      }
+      if (vecTotal != null && vecTotal.size() > 0) {
+        result = new FieldsData[vecTotal.size()];
+        vecTotal.copyInto(result);
+        processCode.add(result);
+        generatedProcesses.add(process);
+      }
+
+    }
+    if (generatedProcesses.size() > 0) {
+      // create the helper class, it is a servlet that manages all combo reloads
+      XmlDocument xmlDocumentHelper = xmlEngine.readXmlTemplate(
+          "org/openbravo/wad/ComboReloadsProcessHelper").createXmlDocument();
+      FieldsData[] processesGenerated = new FieldsData[generatedProcesses.size()];
+      generatedProcesses.copyInto(processesGenerated);
+      FieldsData[][] processData = new FieldsData[generatedProcesses.size()][];
+      for (int i = 0; i < generatedProcesses.size(); i++) {
+        processData[i] = processCode.get(i);
+      }
+
+      xmlDocumentHelper.setData("structure1", processesGenerated);
+      xmlDocumentHelper.setDataArray("reportComboReloadsProcess", "structure1", processData);
+      WadUtility.writeFile(fileDir, "ComboReloadsProcessHelper.java", xmlDocumentHelper.print());
+      log4j.debug("created :" + fileDir + "/ComboReloadsProcessHelper.java");
+    }
+  }
+
+  /**
    * Generates the xml file for a sort type tab.
    * 
    * @param parentsFieldsData
--- a/src-wad/src/org/openbravo/wad/WadActionButton.java	Thu Jun 18 12:25:42 2009 +0200
+++ b/src-wad/src/org/openbravo/wad/WadActionButton.java	Thu Jun 18 11:18:06 2009 +0200
@@ -733,6 +733,7 @@
    *          String with the description for the calc controls.
    * @param jsDateFormat
    *          Date format for js.
+   * @param vecReloads
    * @throws ServletException
    * @throws IOException
    */
@@ -740,7 +741,7 @@
       FieldsData fd, Vector<Object> vecFields, int max_textbox_length,
       int max_size_edition_1_columns, String strLanguage, boolean isGeneric,
       String calendarDescription, String clockDescription, String calculatorDescription,
-      String jsDateFormat) throws ServletException, IOException {
+      String jsDateFormat, Vector<Object> vecReloads) throws ServletException, IOException {
     final String[] discard = { "", "isGeneric", "fieldDiscardProcess" };
     if (fd.xmltext.equals(""))
       discard[0] = "helpDiscard";
@@ -764,6 +765,7 @@
     }
 
     if (efd != null) {
+
       vecFields.addElement(fd.columnname);
       for (int i = 0; i < efd.length; i++)
         vecFields.addElement(efd[i].columnname);
@@ -778,11 +780,11 @@
         WADControl auxControl = null;
         try {
           auxControl = WadUtility.getControl(conn, efd[i], false, (fd.columnname + fd.reference),
-              strLanguage, xmlEngine, false, false, false, false);
+              strLanguage, xmlEngine, false, WadUtility.isInVector(vecReloads, efd[i]
+                  .getField("columnname")), false, false);
         } catch (final Exception ex) {
           throw new ServletException(ex);
         }
-        auxControl.setData("IsComboReload", "N");
 
         html.append("<tr><td class=\"TitleCell\">").append(auxControl.toLabel().replace("\n", ""))
             .append("</td>\n");
@@ -884,6 +886,13 @@
       script.append("  return true;\n");
       script.append("}\n");
 
+      script.append("\nfunction reloadComboReloads").append(fd.reference).append(
+          "(changedField) {\n");
+      script
+          .append("  submitCommandForm(changedField, false, null, '../ad_callouts/ComboReloadsProcessHelper.html', 'hiddenFrame', null, null, true);\n");
+      script.append("  return true;\n");
+      script.append("}\n");
+
       xmlDocument.setParameter("script", script.toString());
     }
     WadUtility.writeFile(fileDir, (fd.columnname + fd.reference) + ".html", xmlDocument.print());
--- a/src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefault.html	Thu Jun 18 12:25:42 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefault.html	Thu Jun 18 11:18:06 2009 +0200
@@ -24,7 +24,7 @@
 <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
 </head>
-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  onload="openServletNewWindow('BUTTONxx', false, null, 'BUTTON', null, null, 450, 600);" id="fieldProcessId">
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  onload="openServletNewWindow('FRAMESxx', false, null, 'BUTTON', null, null, 450, 600);" id="fieldProcessId">
 <form id="form" method="post" action="ActionButton_Responser.html" name="frmMain">
   <input type="hidden" name="Command"></input>
   <input type="hidden" name="IsPopUpCall" value="1"></input>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/ActionButtonDefaultFrames.html	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,30 @@
+<!--
+ *************************************************************************
+ * 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></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="yy?Command=BUTTONxx" id="fieldProcessId"></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/ad_actionButton/ActionButtonDefaultFrames.xml	Thu Jun 18 11:18:06 2009 +0200
@@ -0,0 +1,25 @@
+<?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 id="class" file="ActionButtonDefaultFrames.html"/>
+	<PARAMETER id="fieldProcessId" name="processId" attribute="src" replace="xx" default=""/>
+	<PARAMETER id="fieldProcessId" name="type" attribute="src" replace="yy" default="ActionButton_Responser.html"/>
+	<DISCARD id="discard"/>
+</REPORT>