Centralized Control Changes project merged to trunk
authorIván Perdomo <ivan.perdomo@openbravo.com>
Sat, 22 Nov 2008 13:42:08 +0000
changeset 2072 33f056c0f0c1
parent 2071 d5976047630c
child 2073 e3c4c6280127
Centralized Control Changes project merged to trunk
src-core/src/org/openbravo/base/VariablesBase.java
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_PREFERENCE.xml
src-wad/src/org/openbravo/wad/Configuration_Edition.xmlxml
src-wad/src/org/openbravo/wad/Template_ActionButton.html
src-wad/src/org/openbravo/wad/Template_Edition.html
src-wad/src/org/openbravo/wad/Template_Relation.html
src-wad/src/org/openbravo/wad/Wad.java
src-wad/src/org/openbravo/wad/controls/WADButton.html
src-wad/src/org/openbravo/wad/controls/WADButton.java
src-wad/src/org/openbravo/wad/controls/WADButton.xml
src-wad/src/org/openbravo/wad/controls/WADControl.html
src-wad/src/org/openbravo/wad/controls/WADDate.html
src-wad/src/org/openbravo/wad/controls/WADDateTime.html
src-wad/src/org/openbravo/wad/controls/WADInteger.html
src-wad/src/org/openbravo/wad/controls/WADLink.html
src-wad/src/org/openbravo/wad/controls/WADMemo.html
src-wad/src/org/openbravo/wad/controls/WADNumber.html
src-wad/src/org/openbravo/wad/controls/WADSearch.html
src-wad/src/org/openbravo/wad/controls/WADString.html
src-wad/src/org/openbravo/wad/controls/WADStringEncrypted.html
src-wad/src/org/openbravo/wad/controls/WADTime.html
src-wad/src/org/openbravo/wad/controls/WADYesNo.html
src-wad/src/org/openbravo/wad/controls/WADYesNo.xml
src-wad/src/org/openbravo/wad/javasource.javaxml
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
src/org/openbravo/base/secureApp/LoginUtils.java
src/org/openbravo/base/secureApp/PopUp_Close_Refresh.html
src/org/openbravo/base/secureApp/PopUp_Close_Refresh.xml
src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java
src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java
src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder.java
src/org/openbravo/erpCommon/ad_actionButton/InsertAcces.java
src/org/openbravo/erpCommon/ad_actionButton/ProjectSetType.java
src/org/openbravo/erpCommon/ad_callouts/SL_Order_Tax.java
src/org/openbravo/erpCommon/businessUtility/WindowTabs.java
src/org/openbravo/erpCommon/security/Login_F1.html
src/org/openbravo/erpCommon/utility/NavigationBar.java
src/org/openbravo/erpCommon/utility/OBError.java
src/org/openbravo/erpCommon/utility/Utility.java
src/org/openbravo/erpCommon/utility/Utility_data.xsql
src/org/openbravo/erpCommon/utility/VerticalMenu.html
src/org/openbravo/erpCommon/utility/VerticalMenu.java
src/org/openbravo/erpCommon/utility/VerticalMenu.xml
web/js/appStatus.js
web/js/messages.js
web/js/utils.js
web/js/windowKeyboard.js
--- a/src-core/src/org/openbravo/base/VariablesBase.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-core/src/org/openbravo/base/VariablesBase.java	Sat Nov 22 13:42:08 2008 +0000
@@ -11,6 +11,8 @@
 */
 package org.openbravo.base;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -22,8 +24,10 @@
 import org.apache.commons.fileupload.*;
 import org.apache.commons.fileupload.disk.*;
 import org.apache.commons.fileupload.servlet.*;
+import org.apache.commons.codec.digest.DigestUtils;
 import org.openbravo.utils.FormatUtilities;
 
+
 /**
  * This class is used to manage parameters passed to the servlets either 
  * using the URL with HTTP GET method or through the HTTP POST method. 
@@ -34,6 +38,8 @@
 public class VariablesBase {
   HttpSession session;
   HttpServletRequest httpRequest;
+  private String postDataHash = null;
+  private List<String> sortedParameters = null;
   public boolean isMultipart = false;
   List<FileItem> items;
 
@@ -54,7 +60,7 @@
   @SuppressWarnings("unchecked")
   public VariablesBase(HttpServletRequest request) {
     this.session = request.getSession(true);
-    this.httpRequest = request;    
+    this.httpRequest = request;
     this.isMultipart = ServletFileUpload.isMultipartContent(new ServletRequestContext(request));
     if (isMultipart) {
       DiskFileItemFactory factory = new DiskFileItemFactory();
@@ -81,7 +87,63 @@
     this.session = request.getSession(true);
     this.httpRequest = request;
   }
-
+  
+  /**
+   * Returns the MD5 string hash based on the post data
+   * @return
+   */
+  private String computeHash() {
+	  
+	  long t = 0;
+	  if(log4j.isDebugEnabled()) t = System.currentTimeMillis();
+	  StringBuffer postString = new StringBuffer();
+	  
+	  for(String parameter : sortedParameters()) {			
+		String value = httpRequest.getParameter(parameter);
+		postString.append(parameter + "=" + value + ",");
+	  }
+	  
+	  String s = DigestUtils.md5Hex(postString.toString());
+	  
+	  if(log4j.isDebugEnabled()) {
+		  log4j.debug("calculated hash: " + s);
+		  log4j.debug("post data hash computation took: " + 
+				  String.valueOf(System.currentTimeMillis() - t) + " ms");
+	  }
+	  
+	  return s;
+  }
+  
+  /**
+   * Getter for the postDataHas member
+   * @return The MD5 hash of the post data
+   */
+  public String getPostDataHash() {
+	  if(postDataHash ==  null) {
+		  postDataHash = computeHash();
+	  }
+	  return postDataHash;
+  }
+  
+  /**
+   * Sorts the list of parameters in the request
+   * @return A sorted list of parameters
+   */
+  @SuppressWarnings("unchecked")
+  private List<String> sortedParameters() {
+	  if(sortedParameters == null) {
+		  sortedParameters = new ArrayList<String>();
+		  for(Enumeration e = httpRequest.getParameterNames(); e.hasMoreElements();) {
+			  String parameter = (String) e.nextElement();
+			  if(!parameter.equalsIgnoreCase("Command") && !parameter.contains("ProcessId")) {
+				  sortedParameters.add(parameter);
+			  }
+		  }
+		  Collections.sort(sortedParameters);
+	  }
+	  return sortedParameters;
+  }
+  
   /**
    * Returns the value of the requestParameter passed to the servlet by the  
    * HTTP GET/POST method. If this parameter is not found among the ones 
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -155262,6 +155262,33 @@
 <!--2E175A7785AD4313B24D3E9034B05BAD-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--2E175A7785AD4313B24D3E9034B05BAD**************--></AD_MESSAGE>
 
+<!--2EB6F2EE079E41C3A9E416768353105F**************--><AD_MESSAGE>
+<!--2EB6F2EE079E41C3A9E416768353105F AD_MESSAGE_ID-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <AD_MESSAGE_ID><![CDATA[2EB6F2EE079E41C3A9E416768353105F]]></AD_MESSAGE_ID>
+<!--2EB6F2EE079E41C3A9E416768353105F AD_CLIENT_ID-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2EB6F2EE079E41C3A9E416768353105F AD_ORG_ID-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2EB6F2EE079E41C3A9E416768353105F ISACTIVE-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2EB6F2EE079E41C3A9E416768353105F CREATED-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <CREATED><![CDATA[2008-11-22 14:21:31.0]]></CREATED>
+<!--2EB6F2EE079E41C3A9E416768353105F CREATEDBY-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--2EB6F2EE079E41C3A9E416768353105F UPDATED-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <UPDATED><![CDATA[2008-11-22 14:21:31.0]]></UPDATED>
+<!--2EB6F2EE079E41C3A9E416768353105F UPDATEDBY-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--2EB6F2EE079E41C3A9E416768353105F VALUE-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <VALUE><![CDATA[JS25]]></VALUE>
+<!--2EB6F2EE079E41C3A9E416768353105F MSGTEXT-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <MSGTEXT><![CDATA[There are changes in the current record. Do you want to save the changes?]]></MSGTEXT>
+<!--2EB6F2EE079E41C3A9E416768353105F MSGTYPE-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <MSGTYPE><![CDATA[C]]></MSGTYPE>
+<!--2EB6F2EE079E41C3A9E416768353105F AD_MODULE_ID-->
+<!--2EB6F2EE079E41C3A9E416768353105F-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--2EB6F2EE079E41C3A9E416768353105F**************--></AD_MESSAGE>
+
 <!--32218842A1E740BE9E9FFAEC1B446322**************--><AD_MESSAGE>
 <!--32218842A1E740BE9E9FFAEC1B446322 AD_MESSAGE_ID-->
 <!--32218842A1E740BE9E9FFAEC1B446322-->              <AD_MESSAGE_ID><![CDATA[32218842A1E740BE9E9FFAEC1B446322]]></AD_MESSAGE_ID>
@@ -157342,4 +157369,31 @@
 <!--FF0C79EFEB084C21BD3E764D2E22D96A-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--FF0C79EFEB084C21BD3E764D2E22D96A**************--></AD_MESSAGE>
 
+<!--FF4FA07F57D5456392B6EC6126415605**************--><AD_MESSAGE>
+<!--FF4FA07F57D5456392B6EC6126415605 AD_MESSAGE_ID-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <AD_MESSAGE_ID><![CDATA[FF4FA07F57D5456392B6EC6126415605]]></AD_MESSAGE_ID>
+<!--FF4FA07F57D5456392B6EC6126415605 AD_CLIENT_ID-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF4FA07F57D5456392B6EC6126415605 AD_ORG_ID-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF4FA07F57D5456392B6EC6126415605 ISACTIVE-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF4FA07F57D5456392B6EC6126415605 CREATED-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <CREATED><![CDATA[2008-11-22 14:22:03.0]]></CREATED>
+<!--FF4FA07F57D5456392B6EC6126415605 CREATEDBY-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--FF4FA07F57D5456392B6EC6126415605 UPDATED-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <UPDATED><![CDATA[2008-11-22 14:30:11.0]]></UPDATED>
+<!--FF4FA07F57D5456392B6EC6126415605 UPDATEDBY-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--FF4FA07F57D5456392B6EC6126415605 VALUE-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <VALUE><![CDATA[JS26]]></VALUE>
+<!--FF4FA07F57D5456392B6EC6126415605 MSGTEXT-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <MSGTEXT><![CDATA[The current record could not be saved automatically and you will lose your changes if you continue.\nPress 'Cancel' to go back or 'OK' to discard them and continue with your action.]]></MSGTEXT>
+<!--FF4FA07F57D5456392B6EC6126415605 MSGTYPE-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <MSGTYPE><![CDATA[C]]></MSGTYPE>
+<!--FF4FA07F57D5456392B6EC6126415605 AD_MODULE_ID-->
+<!--FF4FA07F57D5456392B6EC6126415605-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FF4FA07F57D5456392B6EC6126415605**************--></AD_MESSAGE>
+
 </data>
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -300,4 +300,50 @@
 <!--1000100000-->              <VALUE><![CDATA[N]]></VALUE>
 <!--1000100000**************--></AD_PREFERENCE>
 
+<!--343ABBA439F74F9EAE2CAE54B1959101**************--><AD_PREFERENCE>
+<!--343ABBA439F74F9EAE2CAE54B1959101 AD_PREFERENCE_ID-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <AD_PREFERENCE_ID><![CDATA[343ABBA439F74F9EAE2CAE54B1959101]]></AD_PREFERENCE_ID>
+<!--343ABBA439F74F9EAE2CAE54B1959101 AD_CLIENT_ID-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--343ABBA439F74F9EAE2CAE54B1959101 AD_ORG_ID-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--343ABBA439F74F9EAE2CAE54B1959101 ISACTIVE-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--343ABBA439F74F9EAE2CAE54B1959101 CREATED-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <CREATED><![CDATA[2008-10-04 12:00:00.0]]></CREATED>
+<!--343ABBA439F74F9EAE2CAE54B1959101 CREATEDBY-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--343ABBA439F74F9EAE2CAE54B1959101 UPDATED-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <UPDATED><![CDATA[2008-10-04 12:00:00.0]]></UPDATED>
+<!--343ABBA439F74F9EAE2CAE54B1959101 UPDATEDBY-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--343ABBA439F74F9EAE2CAE54B1959101 ATTRIBUTE-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <ATTRIBUTE><![CDATA[ShowConfirmationDefault]]></ATTRIBUTE>
+<!--343ABBA439F74F9EAE2CAE54B1959101 VALUE-->
+<!--343ABBA439F74F9EAE2CAE54B1959101-->              <VALUE><![CDATA[N]]></VALUE>
+<!--343ABBA439F74F9EAE2CAE54B1959101**************--></AD_PREFERENCE>
+
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B**************--><AD_PREFERENCE>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B AD_PREFERENCE_ID-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <AD_PREFERENCE_ID><![CDATA[DE5F76C490CD4199AB2A621B5BA7DF8B]]></AD_PREFERENCE_ID>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B AD_CLIENT_ID-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B AD_ORG_ID-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B ISACTIVE-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B CREATED-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <CREATED><![CDATA[2008-11-07 11:18:46.0]]></CREATED>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B CREATEDBY-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B UPDATED-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <UPDATED><![CDATA[2008-11-07 11:45:37.0]]></UPDATED>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B UPDATEDBY-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B ATTRIBUTE-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <ATTRIBUTE><![CDATA[Autosave]]></ATTRIBUTE>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B VALUE-->
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B-->              <VALUE><![CDATA[Y]]></VALUE>
+<!--DE5F76C490CD4199AB2A621B5BA7DF8B**************--></AD_PREFERENCE>
+
 </data>
--- a/src-wad/src/org/openbravo/wad/Configuration_Edition.xmlxml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Configuration_Edition.xmlxml	Sat Nov 22 13:42:08 2008 +0000
@@ -29,6 +29,7 @@
   <PARAMETER id="paramWindowId" name = "windowId" attribute="value" default=""/>
   <PARAMETER id="paramTabId" name = "tabId" attribute="value" default=""/>
   <PARAMETER id="paramMessageAlert" name="buscador" attribute="onload" replace="zz" default=""/>
+  <PARAMETER id="paramMessageAlert" name="failedAutosave" attribute="onload" replace="yy" default=""/>
   <PARAMETER id="paramDirectory" name="directory" default=""/>
   <PARAMETER id="paramSessionDate" name="paramSessionDate" attribute="value" default=""/>
   <PARAMETER id="paramChanged" name = "changed" attribute="value" default=""/>
@@ -47,6 +48,8 @@
   <PARAMETER id="messageBoxIDTitle" name="messageTitle" default=""/>
   <PARAMETER id="messageBoxIDMessage" name="messageMessage" default=""/>
   <PARAMETER id="scriptOnLoad" name = "scriptOnLoad" default=" "/>
+  <PARAMETER id="mapping" name="mappingName" attribute="value" replace="xxx"></PARAMETER>
+  <PARAMETER id="confirmOnChanges" name="confirmOnChanges" default=""></PARAMETER>
   <PARAMETER_TMP id="hasOrgKey"><PARAMETER id="paramCurrentOrgId" name = "paramCurrentOrgId" attribute="value" default=""/></PARAMETER_TMP>
   
   <PARAMETER_TMP id="hasParent"><PARAMETER id="parentOrg" name="parentOrg" default="" attribute="value"/> </PARAMETER_TMP>
--- a/src-wad/src/org/openbravo/wad/Template_ActionButton.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Template_ActionButton.html	Sat Nov 22 13:42:08 2008 +0000
@@ -83,7 +83,6 @@
 		setWindowTableParentElement();
 		enableShortcuts('popup');
     setBrowserAutoComplete(false);
-		
 
 		onloadClient();
 		setWindowElementFocus('firstElement');
--- a/src-wad/src/org/openbravo/wad/Template_Edition.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Template_Edition.html	Sat Nov 22 13:42:08 2008 +0000
@@ -13,7 +13,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-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
 <script language="JavaScript" type="text/javascript" id="paramLanguage">
   defaultLang = "en_US";
 </script>
+<script language="JavaScript" type="text/javascript" id="confirmOnChanges">var confirmOnChanges = true;</script>
 <script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
@@ -93,25 +94,27 @@
 </script>
 
 </head>
-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="onLoadDo(); zz" onresize="onResizeDo();" id="paramMessageAlert">
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="onLoadDo(); zz yy" onresize="onResizeDo();" id="paramMessageAlert">
 <form id="form" method="post" action="Window_Edition.html" name="frmMain">
-  <input type="hidden" name="Command">
-  <input type="hidden" name="inpCommandType" value="" id="paramCommandType">
-  <input type="hidden" name="inpTabId" value="" id="fieldTabId">
-  <input type="hidden" name="inpParamSessionDate" value="" id="paramSessionDate">
-  <input type="hidden" name="inpLastFieldChanged" id="paramChanged" value="">
-  <input type="hidden" name="inpwindowId" value="" id="paramWindowId">
-  <input type="hidden" name="inpkeyColumnId" value="" id="fieldKey">
-  <input type="hidden" name="inpTableId" value="" id="paramTableId">
-  <input type="hidden" name="inpKeyName" value="inpxx" id="fieldhiddenKeyName">
-  <input type="hidden" name="inpkeyColumnIdInp" value="" id="inpkeyColumnId">
-  <input type="hidden" name="inpKeyReferenceColumnName">
-  <input type="hidden" name="inpTableReferenceId">
-  <input type="hidden" name="inpKeyReferenceId">
-  <input type="hidden" name="inpSecondKey">
-  <input type="hidden" name="inpParentKeyColumn" id="parent" value="">
-  <PARAMETER_TMP id="hasParent"><input type="hidden" name="inpParentOrganization" id="parentOrg" value=""></PARAMETER_TMP> 
-  <PARAMETER_TMP id="hasOrgKey"><input type="hidden" name="inpCurrentOrgId" id="paramCurrentOrgId" value=""></PARAMETER_TMP>  
+  <input type="hidden" name="Command" />
+  <input type="hidden" name="inpCommandType" value="" id="paramCommandType" />
+  <input type="hidden" name="inpTabId" value="" id="fieldTabId" />
+  <input type="hidden" name="inpParamSessionDate" value="" id="paramSessionDate" />
+  <input type="hidden" name="inpLastFieldChanged" id="paramChanged" value="" />
+  <input type="hidden" name="inpwindowId" value="" id="paramWindowId" />
+  <input type="hidden" name="inpkeyColumnId" value="" id="fieldKey" />
+  <input type="hidden" name="inpTableId" value="" id="paramTableId" />
+  <input type="hidden" name="inpKeyName" value="inpxx" id="fieldhiddenKeyName" />
+  <input type="hidden" name="inpkeyColumnIdInp" value="" id="inpkeyColumnId" />
+  <input type="hidden" name="inpKeyReferenceColumnName" />
+  <input type="hidden" name="inpTableReferenceId" />
+  <input type="hidden" name="inpKeyReferenceId" />
+  <input type="hidden" name="inpSecondKey" />
+  <input type="hidden" name="inpParentKeyColumn" id="parent" value="" />
+  <input type="hidden" name="mappingName" id="mapping" value="xxx" />
+  <input type="hidden" name="autosave" id="autosave" value="N" />
+  <PARAMETER_TMP id="hasParent"><input type="hidden" name="inpParentOrganization" id="parentOrg" value="" /></PARAMETER_TMP> 
+  <PARAMETER_TMP id="hasOrgKey"><input type="hidden" name="inpCurrentOrgId" id="paramCurrentOrgId" value="" /></PARAMETER_TMP>  
   <FIELD_TMP id="hiddenControlDesign"></FIELD_TMP>
   <table height="100%" border="0" cellpadding="0" cellspacing="0" id="main">
     <tr>
--- a/src-wad/src/org/openbravo/wad/Template_Relation.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Template_Relation.html	Sat Nov 22 13:42:08 2008 +0000
@@ -33,6 +33,7 @@
 <script language="JavaScript" type="text/javascript" id="paramLanguage">
 	defaultLang = "en_US";
 </script>
+<script language="JavaScript" type="text/javascript" id="confirmOnChanges">var confirmOnChanges = true;</script>
 <script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
--- a/src-wad/src/org/openbravo/wad/Wad.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Wad.java	Sat Nov 22 13:42:08 2008 +0000
@@ -1751,7 +1751,7 @@
         } else if (sfd[i].accesslevel.equals("6") && sfd[i].columnname.equalsIgnoreCase("AD_ORG_ID")) {
           sfd[i].defaultvalue = "\"0\"";
         } else if (!sfd[i].referencevalue.equals("13")){
-          sfd[i].defaultvalue = "Utility.getDefault(this, vars, \"" + sfd[i].columnname + "\", \"" + WadUtility.toJavaString(sfd[i].defaultvalue) + "\", \"" + strWindow + "\", \"" + WadUtility.getWadDefaultValue(sfd[i]) + "\")";
+          sfd[i].defaultvalue = "Utility.getDefault(this, vars, \"" + sfd[i].columnname + "\", \"" + WadUtility.toJavaString(sfd[i].defaultvalue) + "\", \"" + strWindow + "\", \"" + WadUtility.getWadDefaultValue(sfd[i]) + "\", dataField)";
         } else {
           sfd[i].defaultvalue = "\"\"";
         }
--- a/src-wad/src/org/openbravo/wad/controls/WADButton.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADButton.html	Sat Nov 22 13:42:08 2008 +0000
@@ -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-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -22,13 +22,13 @@
 
 
 <div id="xx_inp">
-  <input type="hidden" name="inpxx" value="" onchange="logChanges(this.inputNode);xx();return true;" id="xx"/>
+  <input type="hidden" name="inpxx" value="" onchange="logChanges(this);xx();return true;" id="xx"/>
   <a class="ButtonLinkxx" href="#"
     onfocus="setWindowElementFocus(this); window.status='xx'; return true;"
     onblur="window.status=''; return true;"
     onkeypress="this.className='xx'; return true;"
     onkeyup="this.className='xx'; return true;"
-    onclick="xx();return false;" id="xx_linkBTN">
+    onclick="logClick(yy);xx();return false;" id="xx_linkBTN">
     <table class="Button"
       onmousedown="this.className='xx'; return true;"
       onmouseup="this.className='xx'; return true;"
--- a/src-wad/src/org/openbravo/wad/controls/WADButton.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADButton.java	Sat Nov 22 13:42:08 2008 +0000
@@ -11,7 +11,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-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -57,12 +57,12 @@
     } else {
       if (getData("MappingName").equals("")) {
         text.append("openServletNewWindow('BUTTON").append(FormatUtilities.replace(getData("ColumnName"))).append(getData("AD_Process_ID"));
-        text.append("', false, '").append(getData("TabName")).append("_Edition.html', 'BUTTON', null, true");
+        text.append("', true, '").append(getData("TabName")).append("_Edition.html', 'BUTTON', null, true");
         if (getData("ColumnName").equalsIgnoreCase("CreateFrom")) text.append(",600, 900");
         else text.append(", 600, 900");
         text.append(");");
       } else {
-        text.append("openServletNewWindow('DEFAULT', false, '..");
+        text.append("openServletNewWindow('DEFAULT', true, '..");
         if (!getData("MappingName").startsWith("/")) text.append('/');
         text.append(getData("MappingName")).append("', 'BUTTON', '").append(getData("AD_Process_ID")).append("', true");
         text.append(",600, 900);");
@@ -80,7 +80,7 @@
     xmlDocument.setParameter("name", getData("Name"));
 
     xmlDocument.setParameter("callout", getOnChangeCode());
-    
+    xmlDocument.setParameter("inputId", getData("ColumnName"));
     xmlDocument.setParameter("action", getAction().toString());
     
     boolean isDisabled = (getData("IsReadOnly").equals("Y") || (getData("IsReadOnlyTab").equals("Y") && getData("isReadOnlyDefinedTab").equals("N"))|| getData("IsUpdateable").equals("N"));
@@ -107,7 +107,9 @@
 
     xmlDocument.setParameter("callout", getOnChangeCode());
     
+    xmlDocument.setParameter("inputId", getData("ColumnName"));
     xmlDocument.setParameter("action", getAction().toString());
+    
     boolean isDisabled = (getData("IsReadOnly").equals("Y") || (getData("IsReadOnlyTab").equals("Y") && getData("isReadOnlyDefinedTab").equals("N"))|| getData("IsUpdateable").equals("N"));
     
     if (isDisabled) {
--- a/src-wad/src/org/openbravo/wad/controls/WADButton.xml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADButton.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -25,6 +25,7 @@
   <PARAMETER id="xx" name="callout" attribute="onchange" replace="xx();"/>
   <PARAMETER id="xx_BTNname" name="columnName" attribute="id" replace="xx"/>
   <PARAMETER id="xx_BTNname" name="nameHTML"/>
+  <PARAMETER id="xx_linkBTN" name="inputId" attribute="onclick" replace="yy"/>
   <PARAMETER id="xx_linkBTN" name="action" attribute="onclick" replace="xx();"/>
   <PARAMETER id="xx_linkBTN" name="name" attribute="onfocus" replace="xx"/>
   <PARAMETER id="xx_linkBTN" name="columnName" attribute="id" replace="xx"/>
--- a/src-wad/src/org/openbravo/wad/controls/WADControl.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADControl.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADDate.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADDate.html	Sat Nov 22 13:42:08 2008 +0000
@@ -27,7 +27,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="auto_complete_date(this);" onkeypress="changeToEditingMode();" onchange="validateDateTextBox(this.id);logChanges(this);xx();return true;" displayFormat="xx" saveFormat="xx"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="auto_complete_date(this);" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateDateTextBox(this.id);logChanges(this);xx();return true;" displayFormat="xx" saveFormat="xx"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADDateTime.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADDateTime.html	Sat Nov 22 13:42:08 2008 +0000
@@ -22,7 +22,7 @@
   <table border="0" cellspacing="0" cellpadding="0" summary="" class="TextBox" id="fieldHasButton">
     <tr>
       <td class="TextBox_xx_ContentCell" id="fieldCSS">
-        <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="auto_complete_date(this);" onkeypress="changeToEditingMode();" onchange="validateDateTextBox(this.id);logChanges(this);xx();return true;" displayFormat="xx %H:%M:%S" saveFormat="xx %H:%M:%S"/>
+        <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="auto_complete_date(this);" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateDateTextBox(this.id);logChanges(this);xx();return true;" displayFormat="xx %H:%M:%S" saveFormat="xx %H:%M:%S"/>
       </td>
       <td class="Middle" id="fieldButton">
       </td>
--- a/src-wad/src/org/openbravo/wad/controls/WADInteger.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADInteger.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width number" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateIntegerBox(this.id);logChanges(this);xx();return true;"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width number" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateIntegerBox(this.id);logChanges(this);xx();return true;"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADLink.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADLink.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" maxlength="xx" value="" style="vertical-align: middle;" name="inpxx"onkeyup="" onkeypress="changeToEditingMode();" onchange="validateUrlTextBox(this.id);logChanges(this);xx();return true;" required="false"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" maxlength="xx" value="" style="vertical-align: middle;" name="inpxx"onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateUrlTextBox(this.id);logChanges(this);xx();return true;" required="false"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADMemo.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADMemo.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <textarea id="xx" class="dojoValidateValidxx TextArea_yy_width TextArea_Medium_height" required="false" maxlength='xx' name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateTextArea(this.id);logChanges(this);xx();return true;"></textarea>
+            <textarea id="xx" class="dojoValidateValidxx TextArea_yy_width TextArea_Medium_height" required="false" maxlength='xx' name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTextArea(this.id);logChanges(this);xx();return true;"></textarea>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADNumber.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADNumber.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width number" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateNumberBox(this.id);logChanges(this);xx();return true;"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width number" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateNumberBox(this.id);logChanges(this);xx();return true;"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADSearch.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADSearch.html	Sat Nov 22 13:42:08 2008 +0000
@@ -28,7 +28,7 @@
         <tr>
           <td style="padding-top: 0px;">
             <FIELD_TMP id="fieldHiddens"/>
-            <input type="text" class="dojoValidateValidxx TextBox_yy_width" tabindex="" maxlength="xx" name="inpxx_R" id="xx_R" value="" required="false" onkeypress="changeToEditingMode();" onchange="validateTextBox(this.id);"/>
+            <input type="text" class="dojoValidateValidxx TextBox_yy_width" tabindex="" maxlength="xx" name="inpxx_R" id="xx_R" value="" required="false" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTextBox(this.id);"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADString.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADString.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
+            <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADStringEncrypted.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADStringEncrypted.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
       <table style="border:0px;border-collapse:collapse;">
         <tr>
           <td style="padding-top: 0px;">
-            <input type="password" id="xx" disabled="true" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
+            <input type="password" id="xx" disabled="true" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx" onkeyup="" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTextBox(this.id);logChanges(this);xx();return true;"/>
           </td>
         </tr>
       </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADTime.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADTime.html	Sat Nov 22 13:42:08 2008 +0000
@@ -26,7 +26,7 @@
         <table style="border:0px;border-collapse:collapse;">
           <tr>
             <td style="padding-top: 0px;">
-              <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx"  onkeyup="auto_complete_time(this);" onkeypress="changeToEditingMode();" onchange="validateTimeTextBox(this.id);logChanges(this.inputNode);xx();return true;" displayFormat="%H:%M:%S" saveFormat="%H:%M:%S"/>
+              <input type="text" id="xx" class="dojoValidateValidxx TextBox_yy_width" required="false" value="" maxlength="xx" name="inpxx"  onkeyup="auto_complete_time(this);" onkeypress="changeToEditingMode();" oncut="changeToEditingMode();" onpaste="changeToEditingMode();" onchange="validateTimeTextBox(this.id);logChanges(this.inputNode);xx();return true;" displayFormat="%H:%M:%S" saveFormat="%H:%M:%S"/>
             </td>
           </tr>
         </table>
--- a/src-wad/src/org/openbravo/wad/controls/WADYesNo.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADYesNo.html	Sat Nov 22 13:42:08 2008 +0000
@@ -20,6 +20,6 @@
 
 <FIELD_TMP>
   <div id="xx_inp">
-    <span class="Checkbox_container_NOT_Focused"><input type="checkbox" name="inpxx" id="xx" value="Y" onchange="changeToEditingMode();" onclick="logChanges(this.inputNode);xx();return true;" required="false"/></span>
+    <span class="Checkbox_container_NOT_Focused"><input type="checkbox" name="inpxx" id="xx" value="Y" onchange="changeToEditingMode();" onclick="logChanges(this);xx();return true;" required="false"/></span>
   </div>
 </FIELD_TMP>
--- a/src-wad/src/org/openbravo/wad/controls/WADYesNo.xml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/controls/WADYesNo.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -27,7 +27,7 @@
   <PARAMETER id="xx" name="callout" attribute="onclick" replace="xx();" default=""/>
   <PARAMETER id="xx" name="required" attribute="required"/>
   <PARAMETER id="xx" name="disabled" boolean=" onclick='return false;' readonly=true" withId="paramChecked"/>
-  <PARAMETER id="xx" name="logChanges" attribute="onclick" replace="logChanges(this.inputNode);" default="logChanges(this.inputNode);"/>
+  <PARAMETER id="xx" name="logChanges" attribute="onclick" replace="logChanges(this);" default="logChanges(this);"/>
   <PARAMETER id="xx" name="disabledFalse" attribute="onclick" replace="return true;" default="return true;"/>
 
   <DISCARD id="discard"/>
--- a/src-wad/src/org/openbravo/wad/javasource.javaxml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/javasource.javaxml	Sat Nov 22 13:42:08 2008 +0000
@@ -36,6 +36,7 @@
 import org.openbravo.utils.FormatUtilities;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.scheduling.ProcessBundle;
 import org.openbravo.scheduling.ProcessRunner;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
@@ -66,7 +67,28 @@
 
   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
-
+    Boolean saveRequest = (Boolean) request.getAttribute("autosave");
+    
+    if(saveRequest != null &amp;&amp; saveRequest){
+        OBError myError = new OBError();
+        String commandType = request.getParameter("inpCommandType");
+        String str<KEY_TMP id="keyData">Almacen</KEY_TMP> = request.getParameter("inp<KEY_TMP id="keyData">Almacen</KEY_TMP>");
+        <PARAMETER_TMP id="parent"> String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
+        int total = 0;
+        
+        if(commandType.equalsIgnoreCase("EDIT") &amp;&amp; !str<KEY_TMP id="keyData">Almacen</KEY_TMP>.equals(""))
+            total = saveRecord(vars, myError, 'U'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
+        else
+            total = saveRecord(vars, myError, 'I'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
+        
+        if (!myError.isEmpty() &amp;&amp; total == 0)     
+          throw new OBException(myError.getMessage());
+        
+        vars.setSessionValue(request.getParameter("mappingName") +"|hash", vars.getPostDataHash());
+        
+        return;
+    }
+    
     try {
       tableSQL = new TableSQLData(vars, this, tabId, Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel), Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
     } catch (Exception ex) {
@@ -132,7 +154,7 @@
         response.sendRedirect(strDireccion + "<PARAMETER_TMP id="paramEditReference">xx</PARAMETER_TMP>");
 </PARAMETERS_TMP>
     } else if (vars.commandIn("TAB")) {
-<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getRequiredGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
+<PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>", false, false, true, "");
       vars.removeSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
       <PARAMETER_TMP id="refreshTabParentSession">refreshParentSession(vars, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
 </PARAMETER_TMP>
@@ -274,49 +296,17 @@
       printPageEdit(response, request, vars, false, strLast<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
     } else if (vars.commandIn("SAVE_NEW_RELATION", "SAVE_NEW_NEW", "SAVE_NEW_EDIT")) {
 <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
-      OBError myError = null;
-      <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = null;
-      int total = 0;
-      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
-        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
-        vars.setMessage(tabId, myError);
-      } else {
-        try {
-          data = getEditVariables(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
-  <PARAMETER_TMP id="keySequence">        String strSequence = SequenceIdData.getUUID();
-          log4j.info("Sequence: " + strSequence);
-          data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = strSequence;</PARAMETER_TMP>
-          <PARAMETER_TMP id="client">if (Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),data.adClientId) <FIELDS_TMP id="sectionOrganizationCheck"> &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),data.adOrgId)</FIELDS_TMP>)</PARAMETER_TMP>
-            total = data.insert(this);
-          <PARAMETER_TMP id="client">else {
-            myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
-            vars.setMessage(tabId, myError);
-          }</PARAMETER_TMP>
-        } catch(ServletException ex) {
-          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
-          if (!myError.isConnectionAvailable()) {
-            bdErrorConnection(response);
-            return;
-          } else vars.setMessage(tabId, myError);
-        }
-      }
-      if (myError==null &amp;&amp; total==0) {
-        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=DBExecuteError");
-        vars.setMessage(tabId, myError);
-      }
-      if (myError!=null) {
-        if (data!=null) {
-          data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = "";
-          vars.setEditionData(tabId, data);
-        }
+      OBError myError = new OBError();      
+      int total = saveRecord(vars, myError, 'I'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);      
+      if (!myError.isEmpty()) {        
         response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
-      } else {
-        if (myError==null) {
-          myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
-          myError.setMessage(total + " " + myError.getMessage());
-          vars.setMessage(tabId, myError);
-        }
-        vars.setSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", data.<KEY_TMP id="keyData">Almacen</KEY_TMP>);
+      } 
+      else {
+		if (myError.isEmpty()) {
+		  myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsInserted");
+		  myError.setMessage(total + " " + myError.getMessage());
+		  vars.setMessage(tabId, myError);
+		}        
         if (vars.commandIn("SAVE_NEW_NEW")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=NEW");
         else if (vars.commandIn("SAVE_NEW_EDIT")) response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
         else response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
@@ -324,44 +314,13 @@
     } else if (vars.commandIn("SAVE_EDIT_RELATION", "SAVE_EDIT_NEW", "SAVE_EDIT_EDIT", "SAVE_EDIT_NEXT")) {
 <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");</PARAMETER_TMP>
       String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getRequiredGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>");
-      int total = 0;
-      <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = null;
-      OBError myError = null;
-      if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
-        myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
-        vars.setMessage(tabId, myError);
-      } else {
-        try {
-          data = getEditVariables(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
-          <PARAMETER_TMP id="client">if (Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),data.adClientId) <FIELDS_TMP id="sectionOrganizationCheck"> &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),data.adOrgId)</FIELDS_TMP>)</PARAMETER_TMP>
-            total = data.update(this);
-          <PARAMETER_TMP id="client">else {
-            myError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
-            vars.setMessage(tabId, myError);
-          }</PARAMETER_TMP>
-        } catch(ServletException ex) {
-          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
-          if (!myError.isConnectionAvailable()) {
-            bdErrorConnection(response);
-            return;
-          } else vars.setMessage(tabId, myError);
-        }
-      }
-      if (myError==null &amp;&amp; total==0) {
-        myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=DBExecuteError");
-        vars.setMessage(tabId, myError);
-      }
-      if (myError!=null) {
-        if (data!=null) {
-          <PARAMETERS_TMP id="sectionButtonText">{
-            //BUTTON TEXT FILLING
-            data.<FIELD_TMP id="fieldButtonText"/> = ActionButtonDefaultData.getText(this, vars.getLanguage(), "<FIELD_TMP id="fieldButtonListID"/>", data.getField("<FIELD_TMP id="fieldButtonID"/>"));
-          }</PARAMETERS_TMP>
-          vars.setEditionData(tabId, data);
-        }
+      OBError myError = new OBError();
+      int total = saveRecord(vars, myError, 'U'<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);      
+      if (!myError.isEmpty()) {
         response.sendRedirect(strDireccion + request.getServletPath() + "?Command=EDIT");
-      } else {
-        if (myError==null) {
+      } 
+      else {
+        if (myError.isEmpty()) {
           myError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=RowsUpdated");
           myError.setMessage(total + " " + myError.getMessage());
           vars.setMessage(tabId, myError);
@@ -593,6 +552,7 @@
 */
   <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data getEditVariables(VariablesSecureApp vars<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException,ServletException {
     <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = new <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data();
+    try {
 <FIELDS_TMP id="sectionDetailgetEditVariables">    data.<FIELD_TMP id="fieldName">claveAlmacen</FIELD_TMP> = <FIELD_TMP id="fieldEncryption">FormatUtilities.encryptDecrypt(</FIELD_TMP>vars.get<FIELD_TMP id="fieldType">StringParameter</FIELD_TMP>("inp<FIELD_TMP id="fieldName1">claveAlmacen</FIELD_TMP>"<FIELD_TMP id="fieldDefault">, "D"</FIELD_TMP>)<FIELD_TMP id="fieldEndEncryption">, true)</FIELD_TMP>;</FIELDS_TMP>
       data.createdby = vars.getUser();
       data.updatedby = vars.getUser();
@@ -607,7 +567,11 @@
     <LISTS_TMP id="sectionDetailDocumentsNew">     if (data.<LIST_TMP id="fieldNameDocNew">dd</LIST_TMP>.startsWith("&#60;")) data.<LIST_TMP id="fieldNameDocNew">dd</LIST_TMP> = <LIST_TMP id="fieldValueDocNew">dd</LIST_TMP>;</LISTS_TMP>
 
     <LISTS_TMP id="sectionIdentifyValues">      if (data.<LIST_TMP id="fieldIdentifyColumn">dd</LIST_TMP>.equals("")) data.<LIST_TMP id="fieldIdentifyColumn">dd</LIST_TMP> = <LIST_TMP id="fieldIdentifyValue">dd</LIST_TMP>;</LISTS_TMP>
-
+	}
+    catch(ServletException e) {
+    	vars.setEditionData(tabId, data);
+    	throw e;
+    }
     return data;
   }
 
@@ -904,7 +868,7 @@
         discard[0] = new String ("newDiscard");
       }
     } else {
-      if (dataField.getField("<KEY_TMP id="keyData">Almacen</KEY_TMP>").equals("")) {
+      if (dataField.getField("<KEY_TMP id="keyData">Almacen</KEY_TMP>") == null || dataField.getField("<KEY_TMP id="keyData">Almacen</KEY_TMP>").equals("")) {
         discard[0] = new String ("editDiscard");
         strCommand = "NEW";
         boolNew = true;
@@ -918,13 +882,12 @@
     vars.setSessionValue(windowId + "|<LIST_TMP id="fieldNameParamPrevious">Almacen</LIST_TMP>", str<LIST_TMP id="paramNamePrevious">dd</LIST_TMP>);
     </LISTS_TMP>
    
-    if (dataField==null) {
       if (boolNew || data==null || data.length==0) {
         refreshSessionNew(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);
         data = <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data.set(<PARAMETER_TMP id="parent">strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP><PARAMETER_DEFAULT_TMP id="defaultValues">defaults</PARAMETER_DEFAULT_TMP>);
         <LISTS_TMP id="sectionDetailDocuments">     data[0].<LIST_TMP id="fieldNameDoc">dd</LIST_TMP> = "&#60;" + <LIST_TMP id="fieldValueDoc">dd</LIST_TMP> + "&#62;";</LISTS_TMP>
       }
-    }
+      
     <PARAMETER_TMP id="parent">String currentPOrg=<PARENT_TMP id="parentClass">Almacen</PARENT_TMP>Data.selectOrg(this, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>);</PARAMETER_TMP>
     String currentOrg = (boolNew?"":(dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId")));
     if (!currentOrg.equals("") &amp;&amp; !currentOrg.startsWith("'")) currentOrg = "'"+currentOrg+"'";
@@ -946,8 +909,9 @@
       WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId);
       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
-      if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
-	  else xmlDocument.setParameter("childTabContainer", tabs.childTabs(true));
+      // if (!str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>.equals("")) xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
+	  // else xmlDocument.setParameter("childTabContainer", tabs.childTabs(true));
+	  xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", "<PARAMETER_TMP id="windowName">Window</PARAMETER_TMP>", "W", strReplaceWith, tabs.breadcrumb());
       xmlDocument.setParameter("navigationBar", nav.toString());
       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>_Relation.html", strReplaceWith);
@@ -969,9 +933,11 @@
     xmlDocument.setParameter("commandType", strCommand);
     xmlDocument.setParameter("buscador",buscador);
     xmlDocument.setParameter("windowId", windowId);
-    xmlDocument.setParameter("changed", (strCommand.equals("NEW")?"1":""));
+    xmlDocument.setParameter("changed", "");
     xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
     xmlDocument.setParameter("theme", vars.getTheme());
+    xmlDocument.setParameter("mappingName", UtilityData.selectObjectMapping(this, tabId));
+    xmlDocument.setParameter("confirmOnChanges", Utility.getJSConfirmOnChanges(vars, windowId));
     //xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference", vars.getLanguage()));
 
 <PARAMETER_TMP id="sectionIsHighVolume4">    xmlDocument.setParameter("paramSessionDate", strParamSessionDate);</PARAMETER_TMP>
@@ -991,28 +957,24 @@
       <FIELDS_TMP id="sectionEncryption">data[0].<FIELD_TMP id="fieldEncryptionName">campo</FIELD_TMP>="";</FIELDS_TMP>
     }
     </FIELDS_TMP>
-    if (dataField==null) {
+    
       xmlDocument.setData("structure1",data);
       <PARAMETER_TMP id="hasOrgKey">xmlDocument.setParameter("paramCurrentOrgId",data[0].getField("adOrgId"));</PARAMETER_TMP>
-    } else {
-      <PARAMETER_TMP id="hasOrgKey">
-      try{
-      </PARAMETER_TMP>
-        FieldProvider[] dataAux = new FieldProvider[1];
-        dataAux[0] = dataField;
-        <PARAMETER_TMP id="hasOrgKey">xmlDocument.setParameter("paramCurrentOrgId",data[0].getField("adOrgId"));</PARAMETER_TMP>
-        xmlDocument.setData("structure1",dataAux);
-      <PARAMETER_TMP id="hasOrgKey">
-      }catch (Exception e){
-        if (myMessage!=null) {
-          bdErrorGeneral(response, myMessage.getTitle(), myMessage.getMessage());
-        } else throw new ServletException(e);
-      }
-      </PARAMETER_TMP>
-    }
+   
 <PARAMATER_TMP id="fieldControlsJavaCode"></PARAMATER_TMP>
     xmlDocument.setParameter("scriptOnLoad", getShortcutScript());
     
+    final String refererURL = vars.getSessionValue(tabId + "|requestURL");
+    vars.removeSessionValue(tabId + "|requestURL");
+    if(!refererURL.equals("")) {
+    	final Boolean failedAutosave = (Boolean) vars.getSessionObject(tabId + "|failedAutosave");
+		vars.removeSessionValue(tabId + "|failedAutosave");
+    	if(failedAutosave != null &amp;&amp; failedAutosave) {
+    		final String jsFunction = "continueUserAction('"+refererURL+"');";
+    		xmlDocument.setParameter("failedAutosave", jsFunction);
+    	}
+    }
+    
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
     out.println(xmlDocument.print());
@@ -1112,6 +1074,66 @@
     shortcuts.append(" return true;\n}");
     return shortcuts.toString();
   }
+  
+  private int saveRecord(VariablesSecureApp vars, OBError myError, char type<PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>) throws IOException, ServletException {
+    <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>Data data = null;
+    int total = 0;
+    if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId)) {
+        OBError newError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
+        myError.setError(newError);
+        vars.setMessage(tabId, myError);
+    }
+    else {
+        try {
+            data = getEditVariables(vars<PARAMETER_TMP id="parent">, strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>);            
+            String strSequence = "";
+            if(type == 'I') {                
+<PARAMETER_TMP id="keySequence">        strSequence = SequenceIdData.getUUID();
+                if(log4j.isDebugEnabled()) log4j.debug("Sequence: " + strSequence);
+                data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = strSequence;</PARAMETER_TMP>  
+            }
+            <PARAMETER_TMP id="client">if (Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel),data.adClientId) <FIELDS_TMP id="sectionOrganizationCheck"> &amp;&amp; Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),data.adOrgId)</FIELDS_TMP>){</PARAMETER_TMP>
+		            if(type == 'I')
+		                    total = data.insert(this);
+		                else
+		                    total = data.update(this);		            
+          <PARAMETER_TMP id="client">
+            }
+                else {
+            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage()));
+            myError.setError(newError);            
+          }</PARAMETER_TMP>
+        } catch(ServletException ex) {
+            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
+            myError.setError(newError);              
+        }
+            
+        if (myError.isEmpty() &amp;&amp; total == 0) {
+            OBError newError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=DBExecuteError");
+            myError.setError(newError);
+        }
+        vars.setMessage(tabId, myError);
+            
+        if(!myError.isEmpty()){
+            if(data != null ) {
+                if(type == 'I') {            			
+                    data.<KEY_TMP id="keyData">Almacen</KEY_TMP> = "";
+                }
+                else {                    
+                    <PARAMETERS_TMP id="sectionButtonText">
+                        //BUTTON TEXT FILLING
+                    data.<FIELD_TMP id="fieldButtonText"/> = ActionButtonDefaultData.getText(this, vars.getLanguage(), "<FIELD_TMP id="fieldButtonListID"/>", data.getField("<FIELD_TMP id="fieldButtonID"/>"));
+                    </PARAMETERS_TMP>
+                }
+                vars.setEditionData(tabId, data);
+            }            	
+        }
+        else {
+            vars.setSessionValue(windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", data.<KEY_TMP id="keyData">Almacen</KEY_TMP>);
+        }
+    }
+    return total;
+  }
 
   public String getServletInfo() {
     return "Servlet <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>. This Servlet was made by Wad constructor";
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Sat Nov 22 13:42:08 2008 +0000
@@ -35,6 +35,7 @@
 import java.util.Map;
 import java.util.Properties;
 
+import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
@@ -63,6 +64,7 @@
 import org.openbravo.authentication.AuthenticationManager;
 import org.openbravo.authentication.basic.DefaultAuthenticationManager;
 import org.openbravo.base.HttpBaseServlet;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.erpCommon.security.AccessData;
 import org.openbravo.erpCommon.security.SessionLogin;
@@ -261,8 +263,58 @@
 
       super.initialize(request,response);
       VariablesSecureApp vars1 = new VariablesSecureApp(request, false);
-      if (vars1.getRole().equals("") || hasAccess(vars1))
+      if (vars1.getRole().equals("") || hasAccess(vars1)) {
+
+          final Boolean saveRequest = (Boolean) request.getAttribute("autosave");
+          final String strTabId = vars1.getStringParameter("inpTabId");
+            
+          if(saveRequest == null && strTabId != null) {    	
+        	
+        	  String autoSave = request.getParameter("autosave");
+        	  Boolean failedAutosave = (Boolean) vars1.getSessionObject(strTabId + "|failedAutosave");
+        	  
+        	  if(failedAutosave == null) {
+        		failedAutosave = false;  
+        	  }
+        	  
+        	  if(autoSave != null && autoSave.equalsIgnoreCase("Y") && !failedAutosave) {    			
+    			
+    			if(log4j.isDebugEnabled()){
+	    			log4j.debug("service: saveRequest - "
+	    					+ this.getClass().getCanonicalName() + " - autosave: " 
+	    					+ autoSave);
+    			}
+    			
+    			if(log4j.isDebugEnabled()) { 
+    				log4j.debug(this.getClass().getCanonicalName() + " - hash: " 
+    						+ vars1.getPostDataHash());
+    			}
+    			
+    			String servletMappingName = request.getParameter("mappingName");
+    			
+    			if(servletMappingName != null && 
+    					!Utility.isExcludedFromAutoSave(this.getClass().getCanonicalName()) ) {
+    				
+	    			String hash = vars1.getSessionValue(servletMappingName + "|hash");
+	    			
+	    			if(log4j.isDebugEnabled()) {
+	    				log4j.debug("hash in session: " + hash);
+	    			}
+	    				// Check if the form was previously saved
+	    			if(!hash.equals(vars1.getPostDataHash())) {
+	    				// forward request
+	    				request.setAttribute("autosave", true);
+	    				if(vars1.getCommand().indexOf("BUTTON") != -1)
+	    					request.setAttribute("popupWindow", true);
+	    				if(!forwardRequest(request, response)) {
+	    					   return;
+	    				}
+	    			}
+    			}
+    		}
+          }
         super.serviceInitialized(request,response);
+      }
       else  {
        if ((strPopUp!=null && !strPopUp.equals(""))||(classInfo.type.equals("S")))  
          bdErrorGeneralPopUp(response, Utility.messageBD(this, "Error", variables.getLanguage()), Utility.messageBD(this, "AccessTableNoView", variables.getLanguage()));
@@ -277,6 +329,18 @@
       else if (!myError.isConnectionAvailable()) bdErrorConnection(response);
       else if (strPopUp!=null && !strPopUp.equals("")) bdErrorGeneralPopUp(response, myError.getTitle(), myError.getMessage());
       else bdErrorGeneral(response, myError.getTitle(), myError.getMessage());
+    } catch(OBException e) {
+    	Boolean isAutosaving = (Boolean) request.getAttribute("autosave");
+    	if(isAutosaving) {    		
+    		request.removeAttribute("autosave");
+    		request.removeAttribute("popupWindow");
+    		throw e;
+    	}
+    	else {
+    		log4j.error("Error captured: " + e);
+    		e.printStackTrace();
+    		bdErrorGeneral(response, "Error", e.toString());
+    	}
     } catch (Exception e) {
       log4j.error("Error captured: " + e);
       e.printStackTrace();
@@ -572,6 +636,16 @@
     out.println(xmlDocument.print());
     out.close();
   }
+  
+  public void printPageClosePopUpAndRefresh(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException {
+	if (log4j.isDebugEnabled()) log4j.debug("Output: PopUp Response");
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/base/secureApp/PopUp_Close_Refresh").createXmlDocument();
+    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close(); 
+  }
 
   public void pageErrorCallOut(HttpServletResponse response) throws IOException {
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/base/secureApp/HtmlErrorCallOut").createXmlDocument();
@@ -775,6 +849,58 @@
     }
   }
 
+  /**
+   * Forwards request to the referrer servlet to perform operations like "auto-save"
+   * Note: The referrer servlet should have a hidden input field with mappingName (e.g. /PurchaOrder/Header_Edition.html)
+   * to be able to get a RequestDispatcher
+   * @param request
+   * @param response
+   * @throws IOException
+   * @throws ServletException
+   */
+  public boolean forwardRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+	  String forwardTo = request.getParameter("mappingName");
+	  String autoSave = request.getParameter("autosave");
+	  String commandType = request.getParameter("inpCommandType");
+	  Boolean popupWindow = request.getAttribute("popupWindow") != null ? (Boolean) request.getAttribute("popupWindow") : false;
+	  
+	  // Forwarding request to save the modified record
+	  if(autoSave != null && autoSave.equalsIgnoreCase("Y")) {
+		  if(forwardTo != null && !forwardTo.equals("")) {
+			  RequestDispatcher rd = getServletContext().getRequestDispatcher(forwardTo);
+			  if (rd != null) {
+				  long time = System.currentTimeMillis();
+				  try {
+					  if(log4j.isDebugEnabled()) log4j.debug("forward request to: " + forwardTo);
+					  rd.include(request, response);
+					  if(log4j.isDebugEnabled()) log4j.debug("Request forward took: " + String.valueOf(System.currentTimeMillis() - time) + " ms");
+				  }
+				  catch(OBException e) {
+					  
+					  request.removeAttribute("autosave");
+					  request.removeAttribute("popupWindow");
+					  
+					  VariablesSecureApp vars = new VariablesSecureApp(request);
+					  final String strTabId = vars.getStringParameter("inpTabId");
+					  vars.setSessionObject(strTabId + "|failedAutosave", true);
+					  
+					  if(!popupWindow) {
+						  vars.setSessionValue(strTabId +"|requestURL", request.getRequestURL().toString());
+						  response.sendRedirect(strDireccion + forwardTo + "?Command=" + (commandType != null ? commandType : "NEW"));
+					  }
+					  else { // close pop-up						  
+						  printPageClosePopUpAndRefresh(response, vars);
+					  }					  
+					  return false;
+				  }
+			  }
+		  }
+	  }
+	  request.removeAttribute("autosave");
+	  request.removeAttribute("popupWindow");
+	  return true;
+  }
+
   public String getServletInfo() {
     return "This servlet add some functions (autentication, privileges, application menu, ...) over HttpBaseServlet";
   }
--- a/src/org/openbravo/base/secureApp/LoginUtils.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/base/secureApp/LoginUtils.java	Sat Nov 22 13:42:08 2008 +0000
@@ -118,6 +118,8 @@
           vars.setSessionValue("#ShowTrl", Utility.getPreference(vars, "ShowTrl", ""));
           vars.setSessionValue("#ShowAcct", Utility.getPreference(vars, "ShowAcct", ""));
           vars.setSessionValue("#ShowAudit", Utility.getPreference(vars, "ShowAuditDefault", ""));
+          vars.setSessionValue("#ShowConfirmation", Utility.getPreference(vars, "ShowConfirmationDefault", ""));
+          vars.setSessionValue("#Autosave", Utility.getPreference(vars, "Autosave", ""));
           SystemPreferencesData[] dataSystem = SystemPreferencesData.select(conn);
           if (dataSystem!=null && dataSystem.length>0) {
             vars.setSessionValue("#RecordRange", dataSystem[0].tadRecordrange);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/secureApp/PopUp_Close_Refresh.html	Sat Nov 22 13:42:08 2008 +0000
@@ -0,0 +1,32 @@
+<!--
+ ************************************************************************************
+ * Copyright (C) 2008 Openbravo S.L.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+-->
+<HTML>
+<HEAD>
+<TITLE>Response</TITLE>
+<META http-equiv="Content-Type" content="text/html; charset=UTF-8"></META> 
+<SCRIPT language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></SCRIPT>
+<SCRIPT language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></SCRIPT>
+<SCRIPT language="JavaScript" type="text/javascript" id="paramLanguage">	defaultLang = "en_US";</SCRIPT>
+<SCRIPT language="JavaScript" type="text/javascript">
+function closeThisPage() {
+	var refreshButton = opener.document.getElementById('buttonRefresh');
+	if(refreshButton)
+		refreshButton.onclick();	
+	top.close();
+	return true;
+}
+</SCRIPT>
+</HEAD>
+<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  onload="closeThisPage()">
+<H1>Complementing the operation ?</H1>
+</BODY>
+</HTML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/secureApp/PopUp_Close_Refresh.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ************************************************************************************
+ * Copyright (C) 2008 Openbravo S.L.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+-->
+<REPORT>
+	<template file="PopUp_Close_Refresh.html"/>
+	<PARAMETER id="paramLanguage" name="language"/>
+</REPORT>
--- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java	Sat Nov 22 13:42:08 2008 +0000
@@ -48,7 +48,7 @@
       String strProcessId = vars.getStringParameter("inpProcessId");
       String strWindow = vars.getStringParameter("inpwindowId");
       String strTab = vars.getStringParameter("inpTabId");
-      String strKey = vars.getStringParameter("inpcInvoiceId");
+      String strKey = vars.getGlobalVariable("inpcInvoiceId", strWindow + "|C_Invoice_ID");
       printPage(response, vars, strKey, strWindow, strTab, strProcessId);
     } else if (vars.commandIn("SAVE")) {
       String strKey = vars.getStringParameter("inpcInvoiceId");
--- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromOrder.java	Sat Nov 22 13:42:08 2008 +0000
@@ -46,11 +46,11 @@
 
   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
-
+    
     if (vars.commandIn("DEFAULT")) {
       String strWindowId = vars.getStringParameter("inpwindowId");
       String strSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId);
-      String strKey = vars.getRequiredStringParameter("inpcOrderId");
+      String strKey = vars.getGlobalVariable("inpcOrderId", strWindowId + "|C_Order_ID");
       String strTabId = vars.getStringParameter("inpTabId");
       String strBpartner = vars.getStringParameter("inpcBpartnerId");
       String strmPricelistId = vars.getStringParameter("inpmPricelistId" );
--- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder.java	Sat Nov 22 13:42:08 2008 +0000
@@ -47,12 +47,12 @@
 
   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
-
+    
     if (vars.commandIn("DEFAULT")) {
       String strProcessId = vars.getStringParameter("inpProcessId");
       String strWindow = vars.getStringParameter("inpwindowId");
       String strTab = vars.getStringParameter("inpTabId");
-      String strKey = vars.getRequiredGlobalVariable("inpcOrderId", strWindow + "|C_Order_ID");
+      String strKey = vars.getGlobalVariable("inpcOrderId", strWindow + "|C_Order_ID");
       printPage(response, vars, strKey, strWindow, strTab, strProcessId);
     } else if (vars.commandIn("SAVE")) {
       String strWindow = vars.getStringParameter("inpwindowId");
--- a/src/org/openbravo/erpCommon/ad_actionButton/InsertAcces.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/InsertAcces.java	Sat Nov 22 13:42:08 2008 +0000
@@ -32,7 +32,6 @@
 
 public class InsertAcces extends HttpSecureAppServlet {
   private static final long serialVersionUID = 1L;
-  
 
   public void init (ServletConfig config) {
     super.init(config);
@@ -41,12 +40,12 @@
 
   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
-
+    
     if (vars.commandIn("DEFAULT")) {
       String strProcessId = vars.getStringParameter("inpProcessId");
       String strWindow = vars.getStringParameter("inpwindowId");
       String strTab = vars.getStringParameter("inpTabId");
-      String strKey = vars.getStringParameter("inpadRoleId");
+      String strKey = vars.getGlobalVariable("inpadRoleId", strWindow + "|AD_Role_ID");
       String strMessage="";
       printPage(response, vars, strKey, strWindow, strProcessId, strMessage, strTab);
     } else if(vars.commandIn("GENERATE")){
@@ -63,9 +62,9 @@
         strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html";
       } else strWindowPath = strDefaultServlet;
       OBError myMessage = getPrintPage(response, vars, strKey, strModule,strType);
-      vars.setMessage("InsertAcces",myMessage );
+      vars.setMessage(strTab, myMessage);
       //vars.setSessionValue(strWindow + "|" + strTabName + ".message", messageResult);
-      printPageClosePopUp(response, vars, strWindowPath);
+      printPageClosePopUp(response, vars, strWindowPath);      
     } else pageErrorPopUp(response);
     
 
--- a/src/org/openbravo/erpCommon/ad_actionButton/ProjectSetType.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_actionButton/ProjectSetType.java	Sat Nov 22 13:42:08 2008 +0000
@@ -46,13 +46,13 @@
 
   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
-
+    
     if (vars.commandIn("DEFAULT")) {
       String strProcessId = vars.getStringParameter("inpProcessId");
       String strWindow = vars.getStringParameter("inpwindowId");
       String strTab = vars.getStringParameter("inpTabId");
       String strProjectType = vars.getStringParameter("inpcProjecttypeId", "");
-      String strKey = vars.getRequiredGlobalVariable("inpcProjectId", strWindow + "|C_Project_ID");
+      String strKey = vars.getGlobalVariable("inpcProjectId", strWindow + "|C_Project_ID");
       if (!ProjectSetTypeData.hasProjectType(this, strKey)) printPage(response, vars, strKey, strProjectType, strWindow, strTab, strProcessId);
       else bdError(response, "ProjectSetTypeError", vars.getLanguage());
     } else if (vars.commandIn("SAVE")) {
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_Order_Tax.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Order_Tax.java	Sat Nov 22 13:42:08 2008 +0000
@@ -78,7 +78,7 @@
 	      strCTaxID = Tax.get(this, strMProductID, data[0].dateordered, strADOrgID, strMWarehouseID, (data[0].billtoId.equals("")?strCBPartnerLocationID:data[0].billtoId), strCBPartnerLocationID, data[0].cProjectId, strIsSOTrx.equals("Y"));
 	    }
     }
-    if(!strCTaxID.equals("")) resultado.append("new Array(\"inpcTaxId\", \"" + strCTaxID + "\")\n");
+    if(strCTaxID != null && !strCTaxID.equals("")) resultado.append("new Array(\"inpcTaxId\", \"" + strCTaxID + "\")\n");
 
     resultado.append(");");
     xmlDocument.setParameter("array", resultado.toString());
--- a/src/org/openbravo/erpCommon/businessUtility/WindowTabs.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/businessUtility/WindowTabs.java	Sat Nov 22 13:42:08 2008 +0000
@@ -15,478 +15,672 @@
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
-*/
+ */
 package org.openbravo.erpCommon.businessUtility;
 
+import java.util.Hashtable;
+import java.util.Stack;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.utils.FormatUtilities;
-import org.openbravo.database.ConnectionProvider;
-import org.openbravo.base.secureApp.VariablesSecureApp;
-import java.util.*;
-import org.apache.log4j.Logger ;
-
 
 /**
  * @author Fernando
- *
- * Class in charge of building the application's tabs for each
- * window type.
+ * 
+ *         Class in charge of building the application's tabs for each window
+ *         type.
  */
 public class WindowTabs {
-  static Logger log4j = Logger.getLogger(WindowTabs.class);
-  private VariablesSecureApp vars;
-  private ConnectionProvider conn;
-  private String className = "";
-  private String TabID = "";
-  private String WindowID = "";
-  private String Title = "";
-  private String ID = "";
-  private String action = "";
-  private int level = 0;
-  boolean editView = true;
-  private Hashtable<String, Stack<WindowTabsData>> tabs = new Hashtable<String, Stack<WindowTabsData>>();
-  private Stack<WindowTabsData> breadcrumb = new Stack<WindowTabsData>();
+    static Logger log4j = Logger.getLogger(WindowTabs.class);
+    private VariablesSecureApp vars;
+    private ConnectionProvider conn;
+    private String className = "";
+    private String TabID = "";
+    private String WindowID = "";
+    private String Title = "";
+    private String ID = "";
+    private String action = "";
+    private int level = 0;
+    boolean editView = true;
+    private Hashtable<String, Stack<WindowTabsData>> tabs = new Hashtable<String, Stack<WindowTabsData>>();
+    private Stack<WindowTabsData> breadcrumb = new Stack<WindowTabsData>();
 
-  /**
-   * Constructor
-   * Used by WAD windows.
-   * 
-   * @param _conn: Object with the database connection methods.
-   * @param _vars: Object with the session information.
-   * @param _tabId: String with the id of the tab.
-   * @param _windowId: String with the id of the window.
-   * @throws Exception
-   */
-  public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars, String _tabId, String _windowId,  boolean _editView) throws Exception {
-    this(_conn, _vars, _tabId, _windowId);  
-    this.editView = _editView;
-  }  
-  
-  public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars, String _tabId, String _windowId) throws Exception {
-    if (_conn==null || _vars==null || _tabId==null || _tabId.equals("") || _windowId==null || _windowId.equals("")) throw new Exception("Missing parameters");
-    this.conn = _conn;
-    this.vars = _vars;
-    this.TabID = _tabId;
-    this.WindowID = _windowId;
-    this.action = "W";
-    this.Title = WindowTabsData.selectWindowInfo(this.conn, this.vars.getLanguage(), this.WindowID);
-    getTabs();
-  }
-
-  /**
-   * Constructor
-   * Used by manual windows.
-   * 
-   * @param _conn: Object with the database connection methods.
-   * @param _vars: Object with the session information.
-   * @param _className: String with the form's classname.
-   * @throws Exception
-   */
-  public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars, String _className) throws Exception {
-    if (_conn==null || _vars==null || _className==null || _className.equals("")) throw new Exception("Missing parameters");
-    this.conn = _conn;
-    this.vars = _vars;
-    this.className = _className;
-    getWindowInfo();
-    getTabs();
-  }
-
-  /**
-   * Constructor
-   * Used by processes without javaclass.
-   * 
-   * @param _conn: Object with the database connection methods.
-   * @param _vars: Object with the session information.
-   * @param _className: String with the form's classname.
-   * @throws Exception
-   */
-  public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars, int adProcessId) throws Exception {
-    if (_conn==null || _vars==null) throw new Exception("Missing parameters");
-    this.conn = _conn;
-    this.vars = _vars;
-    this.className = "";
-    getProcessInfo(new Integer(adProcessId).toString());
-    getTabs();
-  }
-  /**
-   * Obtains the information for the process
-   * (For processes not in menu)
-   * 
-   * @throws Exception
-   */
-  private void getProcessInfo(String adProcessId) throws Exception {
-     WindowTabsData[] processInfo = WindowTabsData.selectProcessInfo(this.conn, adProcessId);
-     if (processInfo==null || processInfo.length==0) {
-       log4j.warn("Error while trying to obtain window info for process: " + adProcessId);
-       return;
-     }
-     this.TabID = processInfo[0].adTabId;
-     this.action = processInfo[0].action;
-     this.WindowID = processInfo[0].tabname;
-     
-     processInfo = WindowTabsData.selectMenuInfo(this.conn, this.vars.getLanguage(), this.action, this.TabID);
-     if (processInfo==null || processInfo.length==0) {
-       log4j.warn("Error while trying to obtain window info for process: " + adProcessId);
-       return;
-     }
-     this.ID = processInfo[0].id;
-     this.Title = processInfo[0].name;
-  }
-  /**
-   * Obtains all the window information from database.
-   * (For manual windows)
-   * 
-   * @throws Exception
-   */
-  private void getWindowInfo() throws Exception {
-    WindowTabsData[] windowInfo = WindowTabsData.selectJavaInfo(this.conn, this.className);
-    if (windowInfo==null || windowInfo.length==0) {
-      log4j.warn("Error while trying to obtain window info for class: " + this.className);
-      return;
-    }
-    this.TabID = windowInfo[0].adTabId;
-    this.action = windowInfo[0].action;
-    this.WindowID = windowInfo[0].tabname;
-    windowInfo = WindowTabsData.selectMenuInfo(this.conn, this.vars.getLanguage(), this.action, this.TabID);
-    if (windowInfo==null || windowInfo.length==0) {
-      log4j.warn("Error while trying to obtain window info for class: " + this.className);
-      return;
-    }
-    this.ID = windowInfo[0].id;
-    this.Title = windowInfo[0].name;
-  }
-
-  /**
-   * Gets the menu root element for the selected window.
-   * 
-   * @return String with the menu root element.
-   * @throws Exception
-   */
-  private String getMenuInfo() throws Exception {
-    if (this.action.equals("W")) return WindowTabsData.selectMenu(this.conn, this.vars.getLanguage(), this.WindowID);
-    else return WindowTabsData.selectMenuManual(this.conn, this.vars.getLanguage(), this.ID);
-  }
-
-  /**
-   * Build the internal structure of all the tabs defined for the window.
-   * 
-   * @throws Exception
-   */
-  private void getTabs() throws Exception {
-    WindowTabsData[] tabsAux = null;
-    if (this.action.equals("W")) tabsAux = WindowTabsData.select(this.conn, this.vars.getLanguage(), this.WindowID);
-    else tabsAux = WindowTabsData.selectManual(this.conn, this.TabID, this.vars.getLanguage(), this.ID);
-    int pos=-1;
-    if (tabsAux==null || tabsAux.length==0) {
-      log4j.warn("Error while trying to obtain tabs for id: " + this.TabID);
-      return;
-    }
-    for (int i=0;i<tabsAux.length;i++) {
-      if (tabsAux[i].adTabId.equals(this.TabID)) {
-        pos = i;
-        this.level = Integer.valueOf(tabsAux[i].tablevel).intValue();
-        break;
-      }
-    }
-    if (pos==-1) throw new Exception("Error while trying to locate the tab: " + this.TabID);
-    if (pos < tabsAux.length-1) {
-      if (Integer.valueOf(tabsAux[pos+1].tablevel).intValue() > this.level) getTabsByLevel(tabsAux, pos+1, false);
-      else getTabsByLevel(tabsAux, pos, true);
-    } else getTabsByLevel(tabsAux, pos, true);
-  }
-
-  /**
-   * Used by the getTabs() method to build the internal structure.
-   * 
-   * @param tabsAux: Array with the tabs.
-   * @param pos: Integer with the actual position in the array.
-   * @param register: Boolean to indicates if the actual position must 
-   *                  be saved in the breadcrumb.
-   * @throws Exception
-   */
-  private void getTabsByLevel(WindowTabsData[] tabsAux, int pos, boolean register) throws Exception {
-    if (register) {
-      tabsAux[pos].isbreadcrumb = "Y";
-      this.breadcrumb.push(tabsAux[pos]);
-    }
-    Stack<WindowTabsData> aux = new Stack<WindowTabsData>();
-    aux.push(tabsAux[pos]);
-    String actualLevel = tabsAux[pos].tablevel;
-    for (int i=pos+1;i<tabsAux.length;i++) {
-      if (tabsAux[pos].tablevel.equals(tabsAux[i].tablevel)) aux.push(tabsAux[i]);
-      else if (Integer.valueOf(tabsAux[pos].tablevel).intValue() > Integer.valueOf(tabsAux[i].tablevel).intValue()) break;
-    }
-    int nextPos = -1;
-    Stack<WindowTabsData> result = new Stack<WindowTabsData>();
-    while (!aux.empty()) result.push(aux.pop());
-    for (int i=pos-1;i>=0;i--) {
-      if (tabsAux[pos].tablevel.equals(tabsAux[i].tablevel)) result.push(tabsAux[i]);
-      else if (Integer.valueOf(tabsAux[pos].tablevel).intValue() > Integer.valueOf(tabsAux[i].tablevel).intValue()) {
-        nextPos = i;
-        break;
-      }
-    }
-    if (result.empty()) throw new Exception("Level missed for tab: " + this.TabID + " in level: " + tabsAux[pos].tablevel);
-    this.tabs.put(actualLevel, result);
-    if (nextPos!=-1) getTabsByLevel(tabsAux, nextPos, true);
-  }
-
-  /**
-   * Method to get the parent's tabs of the actual (If exists).
-   * @return String with the HTML text for the tabs.
-   */
-  public String parentTabs() {
-    StringBuffer text = new StringBuffer();
-    if (this.tabs==null) return text.toString();
-    String strShowAcct = "N";
-    String strShowTrl = "N";
-    try {
-      strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct", this.WindowID);
-      strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl", this.WindowID);
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      log4j.error(ex);
-    }
-    boolean isFirst = true;
-    boolean hasParent = (this.level>0);
-    if (!hasParent) return text.append("<td class=\"tabBackGroundInit\"></td>").toString();
-    for (int i = 0;i<this.level;i++) {
-      Stack<WindowTabsData> aux = this.tabs.get(Integer.toString(i));
-      if (aux==null) continue;
-      if (!isFirst) text.append("</tr>\n<tr>\n");
-
-      if (isFirst) text.append("<td class=\"tabBackGroundInit\">\n");
-      if (isFirst) text.append("  <div>\n");
-      if (isFirst) text.append("  <span class=\"tabTitle\">\n");
-      if (isFirst) text.append("    <div class=\"tabTitle_background\">\n");
-      if (isFirst) text.append("      <span class=\"tabTitle_elements_container\">\n");
-      if (isFirst) text.append("        <span class=\"tabTitle_elements_text\">").append(this.Title).append("</span>\n");
-      if (isFirst) text.append("        <span class=\"tabTitle_elements_separator\"><div class=\"tabTitle_elements_separator_icon\"></div></span>\n");
-      if (isFirst) text.append("        <span class=\"tabTitle_elements_image\"><div class=\"tabTitle_elements_image_normal_icon\" id=\"TabStatusIcon\"></div></span>\n");
-      if (isFirst) text.append("      </span>\n");
-      if (isFirst) text.append("    </div>\n");
-      if (isFirst) text.append("  </span>\n");
-      if (isFirst) text.append("</div>\n");
-      if (isFirst) text.append("</td></tr><tr><td class=\"tabBackGround\">");
-
-      else  text.append("<td class=\"tabBackGround\">");
-      if (isFirst) text.append("  <div class=\"marginLeft\">\n");
-      else {
-        text.append("  <table class=\"tabTable\"><tr>\n");
-        text.append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
-        text.append("    <td class=\"tabPaneBackGround\">\n");}
-      boolean isFirstTab = true;
-      if (this.action.equals("W")) {
-        while (!aux.empty()) {
-          WindowTabsData data = aux.pop();
-          if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N") && data.isinfotab.equals("Y")) continue;
-          else if (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N") && data.istranslationtab.equals("Y")) continue;
-          if (!isFirstTab) text.append("<span class=\"tabSeparator\">&nbsp;</span>\n");
-          text.append((isFirstTab && !((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))))?"<div class=\"marginLeft1\">":"<div>").append("<span class=\"dojoTab").append(((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))?(isFirst?"NULL dojoTabparentfirst":" dojoTabparent"):"")).append("\">");
-          text.append("<div><span><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
-          text.append(getUrlCommand(data.adTabId, data.name, Integer.valueOf(data.tablevel).intValue()));
-          text.append("\" onMouseOver=\"return true;\" onMouseOut=\"return true;\" id=\""+data.tabnameid+"\">").append(data.tabname).append("</a></span></div></span>\n");
-          isFirstTab = false;
-        }
-        text.append("  </div>\n");
-      }
-      if (isFirst) text.append("  </div>\n");
-      else {
-        text.append("    <td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
-        text.append("  </tr></table>\n");
-      }
-      text.append("</td>\n");
-      isFirst = false;
-    }
-    return text.toString();
-  }
-
-  /**
-   * Method to get the tabs of the same level as the actual.
-   * 
-   * @return String with the HTML of the tabs.
-   */
-  public String mainTabs() {
-    StringBuffer text = new StringBuffer();
-    if (this.tabs==null) return text.toString();
-    String strShowAcct = "N";
-    String strShowTrl = "N";
-    try {
-      strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct", this.WindowID);
-      strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl", this.WindowID);
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      log4j.error(ex);
-    }
-    boolean hasParent = (this.level>0);
-    Stack<WindowTabsData> aux = this.tabs.get(Integer.toString(this.level));
-    if (aux==null) return text.toString();
- 
-    if (!hasParent) text.append("<td class=\"tabBackGroundInit\">\n");
-    if (!hasParent) text.append("  <div>\n");
-    if (!hasParent) text.append("  <span class=\"tabTitle\">\n");
-    if (!hasParent) text.append("    <div class=\"tabTitle_background\">\n");
-    if (!hasParent) text.append("      <span class=\"tabTitle_elements_container\">\n");
-    if (!hasParent) text.append("        <span class=\"tabTitle_elements_text\">").append(this.Title).append("</span>\n");
-    if (!hasParent) text.append("        <span class=\"tabTitle_elements_separator\"><div class=\"tabTitle_elements_separator_icon\"></div></span>\n");
-    if (!hasParent) text.append("        <span class=\"tabTitle_elements_image\"><div class=\"tabTitle_elements_image_normal_icon\" id=\"TabStatusIcon\"></div></span>\n");
-    if (!hasParent) text.append("      </span>\n");
-    if (!hasParent) text.append("    </div>\n");
-    if (!hasParent) text.append("  </span>\n");
-    if (!hasParent) text.append("</div>\n");
-    if (!hasParent) text.append("</td></tr><tr>");
-    text.append("<td class=\"tabBackGround\">\n");
-    if (!hasParent) text.append("  <div class=\"marginLeft\">\n");
-    else {
-      text.append("  <table class=\"tabTable\"><tr>\n");
-      text.append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
-      text.append("    <td class=\"tabPaneBackGround\">\n");}
-    boolean isFirstTab = true;
-    if (this.action.equals("W")) {
-      while (!aux.empty()) {
-        WindowTabsData data = aux.pop();
-        if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N") && data.isinfotab.equals("Y")) continue;
-        else if (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N") && data.istranslationtab.equals("Y")) continue;
-        if (!isFirstTab) text.append("<span class=\"tabSeparator\">&nbsp;</span>\n");
-        text.append((isFirstTab && !((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))))?"<div class=\"marginLeft1\">":"<div>").append("<span class=\"").append(((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))?(!hasParent?"dojoTabcurrentfirst":"dojoTabcurrent"):"dojoTab")).append("\">"); //FIXME: extra space before the css className
-        text.append("<div><span><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
-        text.append(getUrlCommand(data.adTabId, data.name, Integer.valueOf(data.tablevel).intValue()));
-        text.append("\" onMouseOver=\"return true;\" onMouseOut=\"return true;\" id=\""+data.tabnameid+"\">").append(data.tabname).append("</a></span></div></span>\n");
-        isFirstTab = false;
-      }
-      text.append("  </div>\n");
+    /**
+     * Constructor Used by WAD windows.
+     * 
+     * @param _conn
+     *            Object with the database connection methods.
+     * @param _vars
+     *            Object with the session information.
+     * @param _tabId
+     *            String with the id of the tab.
+     * @param _windowId
+     *            String with the id of the window.
+     * @throws Exception
+     */
+    public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars,
+            String _tabId, String _windowId, boolean _editView)
+            throws Exception {
+        this(_conn, _vars, _tabId, _windowId);
+        this.editView = _editView;
     }
 
-    if (!hasParent) text.append("  </div>\n");
-    else {
-      text.append("    <td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
-      text.append("  </tr></table>\n");
+    public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars,
+            String _tabId, String _windowId) throws Exception {
+        if (_conn == null || _vars == null || _tabId == null
+                || _tabId.equals("") || _windowId == null
+                || _windowId.equals(""))
+            throw new Exception("Missing parameters");
+        this.conn = _conn;
+        this.vars = _vars;
+        this.TabID = _tabId;
+        this.WindowID = _windowId;
+        this.action = "W";
+        this.Title = WindowTabsData.selectWindowInfo(this.conn, this.vars
+                .getLanguage(), this.WindowID);
+        getTabs();
     }
-    text.append("</td>\n");
-    return text.toString();
-  }
 
-  /**
-   * Method to get the child tabs from the actual.
-   * 
-   * @return String with the HTML of the tabs.
-   */
-  public String childTabs(boolean readOnly) {
-    StringBuffer text = new StringBuffer();
-    if (this.tabs==null) return text.append("<td class=\"tabTabbarBackGround\"></td>").toString();
-    String strShowAcct = "N";
-    String strShowTrl = "N";
-    try {
-      strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct", this.WindowID);
-      strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl", this.WindowID);
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      log4j.error(ex);
+    /**
+     * Constructor Used by manual windows.
+     * 
+     * @param _conn
+     *            Object with the database connection methods.
+     * @param _vars
+     *            Object with the session information.
+     * @param _className
+     *            String with the form's classname.
+     * @throws Exception
+     */
+    public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars,
+            String _className) throws Exception {
+        if (_conn == null || _vars == null || _className == null
+                || _className.equals(""))
+            throw new Exception("Missing parameters");
+        this.conn = _conn;
+        this.vars = _vars;
+        this.className = _className;
+        getWindowInfo();
+        getTabs();
     }
-    Stack<WindowTabsData> aux = this.tabs.get(Integer.toString(this.level+1));
-    if (aux==null) return text.append("<td class=\"tabTabbarBackGround\"></td>").toString();
-    text.append("<td class=\"tabBackGround\">\n");
-    text.append("  <table class=\"tabTable\"><tr>\n");
-    text.append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
-    text.append("    <td class=\"tabPaneBackGround\"><div class=\"marginLeft1\">\n");
-    boolean isFirst = true;
-    while (!aux.empty()) {
-      WindowTabsData data = aux.pop();
-      if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N") && data.isinfotab.equals("Y")) continue;
-      else if (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N") && data.istranslationtab.equals("Y")) continue;
-      if (!isFirst) text.append("<span class=\"tabSeparator\">&nbsp;</span>\n");
-      isFirst = false;
-      text.append("<span class=\"dojoTab").append(((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))?" current":"")).append("\">");
-      text.append("<div><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
-      if(readOnly) text.append("return false;");
-      else text.append(getUrlCommand(data.adTabId, data.name, Integer.valueOf(data.tablevel).intValue()));
-      text.append("\" onMouseOver=\"return true;\" onMouseOut=\"return true;\"  id=\""+data.tabnameid+"\">").append(data.tabname).append("</a></div></span>\n");
+
+    /**
+     * Constructor Used by processes without javaclass.
+     * 
+     * @param _conn
+     *            Object with the database connection methods.
+     * @param _vars
+     *            Object with the session information.
+     * @param _className
+     *            String with the form's classname.
+     * @throws Exception
+     */
+    public WindowTabs(ConnectionProvider _conn, VariablesSecureApp _vars,
+            int adProcessId) throws Exception {
+        if (_conn == null || _vars == null)
+            throw new Exception("Missing parameters");
+        this.conn = _conn;
+        this.vars = _vars;
+        this.className = "";
+        getProcessInfo(new Integer(adProcessId).toString());
+        getTabs();
     }
-    text.append("    </div></td><td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
-    text.append("  </tr></table>\n");
-    text.append("</td>\n");
-    return text.toString();
-  }
-  
-  public String childTabs() {
-    return childTabs(false);
-  }
 
-/*  public String childTabs() {
-    StringBuffer text = new StringBuffer();
-    if (this.tabs==null) return text.toString();
-    String strShowAcct = "N";
-    String strShowTrl = "N";
-    try {
-      strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct", this.WindowID);
-      strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl", this.WindowID);
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      log4j.error(ex);
+    /**
+     * Obtains the information for the process (For processes not in menu)
+     * 
+     * @throws Exception
+     */
+    private void getProcessInfo(String adProcessId) throws Exception {
+        WindowTabsData[] processInfo = WindowTabsData.selectProcessInfo(
+                this.conn, adProcessId);
+        if (processInfo == null || processInfo.length == 0) {
+            log4j.warn("Error while trying to obtain window info for process: "
+                    + adProcessId);
+            return;
+        }
+        this.TabID = processInfo[0].adTabId;
+        this.action = processInfo[0].action;
+        this.WindowID = processInfo[0].tabname;
+
+        processInfo = WindowTabsData.selectMenuInfo(this.conn, this.vars
+                .getLanguage(), this.action, this.TabID);
+        if (processInfo == null || processInfo.length == 0) {
+            log4j.warn("Error while trying to obtain window info for process: "
+                    + adProcessId);
+            return;
+        }
+        this.ID = processInfo[0].id;
+        this.Title = processInfo[0].name;
     }
-    Stack<WindowTabsData> aux = (Stack<WindowTabsData>) this.tabs.get(Integer.toString(this.level+1));
-    if (aux==null) return text.toString();
-    text.append("<td class=\"tabPaneBackGround dojoTabContainerChild dojoTabLabels-bottom\">\n");
-    text.append("<div>\n");
-    while (!aux.empty()) {
-      WindowTabsData data = (WindowTabsData) aux.pop();
-      if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N") && data.isinfotab.equals("Y")) continue;
-      else if (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N") && data.istranslationtab.equals("Y")) continue;
-      text.append("<span class=\"dojoTab").append(((data.adTabId.equals(this.TabID) || data.isbreadcrumb.equals("Y"))?" current":"")).append("\">");
-      text.append("<div><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
-      text.append(getUrlCommand(data.adTabId, data.name, Integer.valueOf(data.tablevel).intValue()));
-      text.append("\" onMouseOver=\"return true;\" onMouseOut=\"return true;\">").append(data.tabname).append("</a></div></span>\n");
+
+    /**
+     * Obtains all the window information from database. (For manual windows)
+     * 
+     * @throws Exception
+     */
+    private void getWindowInfo() throws Exception {
+        WindowTabsData[] windowInfo = WindowTabsData.selectJavaInfo(this.conn,
+                this.className);
+        if (windowInfo == null || windowInfo.length == 0) {
+            log4j.warn("Error while trying to obtain window info for class: "
+                    + this.className);
+            return;
+        }
+        this.TabID = windowInfo[0].adTabId;
+        this.action = windowInfo[0].action;
+        this.WindowID = windowInfo[0].tabname;
+        windowInfo = WindowTabsData.selectMenuInfo(this.conn, this.vars
+                .getLanguage(), this.action, this.TabID);
+        if (windowInfo == null || windowInfo.length == 0) {
+            log4j.warn("Error while trying to obtain window info for class: "
+                    + this.className);
+            return;
+        }
+        this.ID = windowInfo[0].id;
+        this.Title = windowInfo[0].name;
     }
-    text.append("</div>\n");
-    text.append("</td>\n");
-    return text.toString();
-  }*/
 
-  /**
-   * Method to obtain the breadcrumb for this tab.
-   * 
-   * @return String with the HTML of the breadcrumb.
-   */
-  public String breadcrumb() {
-    StringBuffer text = new StringBuffer();
-    if (this.breadcrumb==null || this.breadcrumb.empty()) return text.toString();
-    boolean isFirst = true;
-    try {
-      text.append("<span>").append(getMenuInfo()).append("</span>\n");
-      text.append("&nbsp;||&nbsp;\n");
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      log4j.error("Failed when trying to get parent menu element for breadcrumb");
+    /**
+     * Gets the menu root element for the selected window.
+     * 
+     * @return String with the menu root element.
+     * @throws Exception
+     */
+    private String getMenuInfo() throws Exception {
+        if (this.action.equals("W"))
+            return WindowTabsData.selectMenu(this.conn,
+                    this.vars.getLanguage(), this.WindowID);
+        else
+            return WindowTabsData.selectMenuManual(this.conn, this.vars
+                    .getLanguage(), this.ID);
     }
-    while (!this.breadcrumb.empty()) {
-      WindowTabsData data = this.breadcrumb.pop();
-      if (!isFirst) text.append("&nbsp;&gt;&gt;&nbsp;\n");
-      else isFirst = false;
-      if (!this.breadcrumb.empty()) {
-        text.append("<a class=\"Link\" onmouseover=\"return true;\" href=\"#\" onclick=\"");
-        text.append(getUrlCommand(data.adTabId, data.name, Integer.valueOf(data.tablevel).intValue()));
-        text.append("\" onmouseout=\"return true;\">").append(data.tabname).append("</a>\n");
-      } else text.append(data.tabname).append("\n");
+
+    /**
+     * Build the internal structure of all the tabs defined for the window.
+     * 
+     * @throws Exception
+     */
+    private void getTabs() throws Exception {
+        WindowTabsData[] tabsAux = null;
+        if (this.action.equals("W"))
+            tabsAux = WindowTabsData.select(this.conn, this.vars.getLanguage(),
+                    this.WindowID);
+        else
+            tabsAux = WindowTabsData.selectManual(this.conn, this.TabID,
+                    this.vars.getLanguage(), this.ID);
+        int pos = -1;
+        if (tabsAux == null || tabsAux.length == 0) {
+            log4j.warn("Error while trying to obtain tabs for id: "
+                    + this.TabID);
+            return;
+        }
+        for (int i = 0; i < tabsAux.length; i++) {
+            if (tabsAux[i].adTabId.equals(this.TabID)) {
+                pos = i;
+                this.level = Integer.valueOf(tabsAux[i].tablevel).intValue();
+                break;
+            }
+        }
+        if (pos == -1)
+            throw new Exception("Error while trying to locate the tab: "
+                    + this.TabID);
+        if (pos < tabsAux.length - 1) {
+            if (Integer.valueOf(tabsAux[pos + 1].tablevel).intValue() > this.level)
+                getTabsByLevel(tabsAux, pos + 1, false);
+            else
+                getTabsByLevel(tabsAux, pos, true);
+        } else
+            getTabsByLevel(tabsAux, pos, true);
     }
-    return text.toString();
-  }
 
-  /**
-   * Auxiliar method to get the click command for the elements.
-   * 
-   * @param _tabId: String with the id of the tab.
-   * @param _tabName: String with the tab's name.
-   * @param _level: Integer with the tab's level.
-   * @return String with the javascript command.
-   */
-  private String getUrlCommand(String _tabId, String _tabName, int _level) {
-    StringBuffer text = new StringBuffer();
-    if (!_tabId.equals(this.TabID) && this.level+1>=_level) {
-      text.append("submitCommandForm('").append(((this.level>_level)?"DEFAULT":"TAB")).append("', ");
-      text.append((this.level<_level && !editView)?"true":"false").append(", null, '");
-      text.append(FormatUtilities.replace(_tabName)).append("_Relation.html', '_self', null, true);");
+    /**
+     * Used by the getTabs() method to build the internal structure.
+     * 
+     * @param tabsAux
+     *            Array with the tabs.
+     * @param pos
+     *            Integer with the actual position in the array.
+     * @param register
+     *            Boolean to indicates if the actual position must be saved in
+     *            the breadcrumb.
+     * @throws Exception
+     */
+    private void getTabsByLevel(WindowTabsData[] tabsAux, int pos,
+            boolean register) throws Exception {
+        if (register) {
+            tabsAux[pos].isbreadcrumb = "Y";
+            this.breadcrumb.push(tabsAux[pos]);
+        }
+        final Stack<WindowTabsData> aux = new Stack<WindowTabsData>();
+        aux.push(tabsAux[pos]);
+        final String actualLevel = tabsAux[pos].tablevel;
+        for (int i = pos + 1; i < tabsAux.length; i++) {
+            if (tabsAux[pos].tablevel.equals(tabsAux[i].tablevel))
+                aux.push(tabsAux[i]);
+            else if (Integer.valueOf(tabsAux[pos].tablevel).intValue() > Integer
+                    .valueOf(tabsAux[i].tablevel).intValue())
+                break;
+        }
+        int nextPos = -1;
+        final Stack<WindowTabsData> result = new Stack<WindowTabsData>();
+        while (!aux.empty())
+            result.push(aux.pop());
+        for (int i = pos - 1; i >= 0; i--) {
+            if (tabsAux[pos].tablevel.equals(tabsAux[i].tablevel))
+                result.push(tabsAux[i]);
+            else if (Integer.valueOf(tabsAux[pos].tablevel).intValue() > Integer
+                    .valueOf(tabsAux[i].tablevel).intValue()) {
+                nextPos = i;
+                break;
+            }
+        }
+        if (result.empty())
+            throw new Exception("Level missed for tab: " + this.TabID
+                    + " in level: " + tabsAux[pos].tablevel);
+        this.tabs.put(actualLevel, result);
+        if (nextPos != -1)
+            getTabsByLevel(tabsAux, nextPos, true);
     }
-    text.append("return false;");
-    return text.toString();
-  }
-}
+
+    /**
+     * Method to get the parent's tabs of the actual (If exists).
+     * 
+     * @return String with the HTML text for the tabs.
+     */
+    public String parentTabs() {
+        final StringBuffer text = new StringBuffer();
+        if (this.tabs == null)
+            return text.toString();
+        String strShowAcct = "N";
+        String strShowTrl = "N";
+        try {
+            strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct",
+                    this.WindowID);
+            strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl",
+                    this.WindowID);
+        } catch (final Exception ex) {
+            ex.printStackTrace();
+            log4j.error(ex);
+        }
+        boolean isFirst = true;
+        final boolean hasParent = (this.level > 0);
+        if (!hasParent)
+            return text.append("<td class=\"tabBackGroundInit\"></td>")
+                    .toString();
+        for (int i = 0; i < this.level; i++) {
+            final Stack<WindowTabsData> aux = this.tabs
+                    .get(Integer.toString(i));
+            if (aux == null)
+                continue;
+            if (!isFirst)
+                text.append("</tr>\n<tr>\n");
+
+            if (isFirst)
+                text.append("<td class=\"tabBackGroundInit\">\n");
+            if (isFirst)
+                text.append("  <div>\n");
+            if (isFirst)
+                text.append("  <span class=\"tabTitle\">\n");
+            if (isFirst)
+                text.append("    <div class=\"tabTitle_background\">\n");
+            if (isFirst)
+                text
+                        .append("      <span class=\"tabTitle_elements_container\">\n");
+            if (isFirst)
+                text.append("        <span class=\"tabTitle_elements_text\">")
+                        .append(this.Title).append("</span>\n");
+            if (isFirst)
+                text
+                        .append("        <span class=\"tabTitle_elements_separator\"><div class=\"tabTitle_elements_separator_icon\"></div></span>\n");
+            if (isFirst)
+                text
+                        .append("        <span class=\"tabTitle_elements_image\"><div class=\"tabTitle_elements_image_normal_icon\" id=\"TabStatusIcon\"></div></span>\n");
+            if (isFirst)
+                text.append("      </span>\n");
+            if (isFirst)
+                text.append("    </div>\n");
+            if (isFirst)
+                text.append("  </span>\n");
+            if (isFirst)
+                text.append("</div>\n");
+            if (isFirst)
+                text.append("</td></tr><tr><td class=\"tabBackGround\">");
+
+            else
+                text.append("<td class=\"tabBackGround\">");
+            if (isFirst)
+                text.append("  <div class=\"marginLeft\">\n");
+            else {
+                text.append("  <table class=\"tabTable\"><tr>\n");
+                text
+                        .append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
+                text.append("    <td class=\"tabPaneBackGround\">\n");
+            }
+            boolean isFirstTab = true;
+            if (this.action.equals("W")) {
+                while (!aux.empty()) {
+                    final WindowTabsData data = aux.pop();
+                    if (!data.adTabId.equals(this.TabID)
+                            && strShowAcct.equals("N")
+                            && data.isinfotab.equals("Y"))
+                        continue;
+                    else if (!data.adTabId.equals(this.TabID)
+                            && strShowTrl.equals("N")
+                            && data.istranslationtab.equals("Y"))
+                        continue;
+                    if (!isFirstTab)
+                        text
+                                .append("<span class=\"tabSeparator\">&nbsp;</span>\n");
+                    text
+                            .append(
+                                    (isFirstTab && !((data.adTabId
+                                            .equals(this.TabID) || data.isbreadcrumb
+                                            .equals("Y")))) ? "<div class=\"marginLeft1\">"
+                                            : "<div>")
+                            .append("<span class=\"dojoTab")
+                            .append(
+                                    ((data.adTabId.equals(this.TabID) || data.isbreadcrumb
+                                            .equals("Y")) ? (isFirst ? "NULL dojoTabparentfirst"
+                                            : " dojoTabparent")
+                                            : "")).append("\">");
+                    text
+                            .append("<div><span><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
+                    text.append(getUrlCommand(data.adTabId, data.name, Integer
+                            .valueOf(data.tablevel).intValue()));
+                    text.append(
+                            "\" onMouseOver=\"return true;\" onMouseOut=\"return true;\" id=\""
+                                    + data.tabnameid + "\">").append(
+                            data.tabname).append("</a></span></div></span>\n");
+                    isFirstTab = false;
+                }
+                text.append("  </div>\n");
+            }
+            if (isFirst)
+                text.append("  </div>\n");
+            else {
+                text
+                        .append("    <td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
+                text.append("  </tr></table>\n");
+            }
+            text.append("</td>\n");
+            isFirst = false;
+        }
+        return text.toString();
+    }
+
+    /**
+     * Method to get the tabs of the same level as the actual.
+     * 
+     * @return String with the HTML of the tabs.
+     */
+    public String mainTabs() {
+        final StringBuffer text = new StringBuffer();
+        if (this.tabs == null)
+            return text.toString();
+        String strShowAcct = "N";
+        String strShowTrl = "N";
+        try {
+            strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct",
+                    this.WindowID);
+            strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl",
+                    this.WindowID);
+        } catch (final Exception ex) {
+            ex.printStackTrace();
+            log4j.error(ex);
+        }
+        final boolean hasParent = (this.level > 0);
+        final Stack<WindowTabsData> aux = this.tabs.get(Integer
+                .toString(this.level));
+        if (aux == null)
+            return text.toString();
+
+        if (!hasParent)
+            text.append("<td class=\"tabBackGroundInit\">\n");
+        if (!hasParent)
+            text.append("  <div>\n");
+        if (!hasParent)
+            text.append("  <span class=\"tabTitle\">\n");
+        if (!hasParent)
+            text.append("    <div class=\"tabTitle_background\">\n");
+        if (!hasParent)
+            text.append("      <span class=\"tabTitle_elements_container\">\n");
+        if (!hasParent)
+            text.append("        <span class=\"tabTitle_elements_text\">")
+                    .append(this.Title).append("</span>\n");
+        if (!hasParent)
+            text
+                    .append("        <span class=\"tabTitle_elements_separator\"><div class=\"tabTitle_elements_separator_icon\"></div></span>\n");
+        if (!hasParent)
+            text
+                    .append("        <span class=\"tabTitle_elements_image\"><div class=\"tabTitle_elements_image_normal_icon\" id=\"TabStatusIcon\"></div></span>\n");
+        if (!hasParent)
+            text.append("      </span>\n");
+        if (!hasParent)
+            text.append("    </div>\n");
+        if (!hasParent)
+            text.append("  </span>\n");
+        if (!hasParent)
+            text.append("</div>\n");
+        if (!hasParent)
+            text.append("</td></tr><tr>");
+        text.append("<td class=\"tabBackGround\">\n");
+        if (!hasParent)
+            text.append("  <div class=\"marginLeft\">\n");
+        else {
+            text.append("  <table class=\"tabTable\"><tr>\n");
+            text
+                    .append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
+            text.append("    <td class=\"tabPaneBackGround\">\n");
+        }
+        boolean isFirstTab = true;
+        if (this.action.equals("W")) {
+            while (!aux.empty()) {
+                final WindowTabsData data = aux.pop();
+                if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N")
+                        && data.isinfotab.equals("Y"))
+                    continue;
+                else if (!data.adTabId.equals(this.TabID)
+                        && strShowTrl.equals("N")
+                        && data.istranslationtab.equals("Y"))
+                    continue;
+                if (!isFirstTab)
+                    text.append("<span class=\"tabSeparator\">&nbsp;</span>\n");
+                text
+                        .append(
+                                (isFirstTab && !((data.adTabId
+                                        .equals(this.TabID) || data.isbreadcrumb
+                                        .equals("Y")))) ? "<div class=\"marginLeft1\">"
+                                        : "<div>")
+                        .append("<span class=\"")
+                        .append(
+                                ((data.adTabId.equals(this.TabID) || data.isbreadcrumb
+                                        .equals("Y")) ? (!hasParent ? "dojoTabcurrentfirst"
+                                        : "dojoTabcurrent")
+                                        : "dojoTab")).append("\">");
+                text
+                        .append("<div><span><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
+                text.append(getUrlCommand(data.adTabId, data.name, Integer
+                        .valueOf(data.tablevel).intValue()));
+                text.append(
+                        "\" onMouseOver=\"return true;\" onMouseOut=\"return true;\" id=\""
+                                + data.tabnameid + "\">").append(data.tabname)
+                        .append("</a></span></div></span>\n");
+                isFirstTab = false;
+            }
+            text.append("  </div>\n");
+        }
+
+        if (!hasParent)
+            text.append("  </div>\n");
+        else {
+            text
+                    .append("    <td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
+            text.append("  </tr></table>\n");
+        }
+        text.append("</td>\n");
+        return text.toString();
+    }
+
+    /**
+     * Method to get the child tabs from the actual.
+     * 
+     * @return String with the HTML of the tabs.
+     */
+    public String childTabs(boolean readOnly) {
+        final StringBuffer text = new StringBuffer();
+        if (this.tabs == null)
+            return text.append("<td class=\"tabTabbarBackGround\"></td>")
+                    .toString();
+        String strShowAcct = "N";
+        String strShowTrl = "N";
+        try {
+            strShowAcct = Utility.getContext(this.conn, this.vars, "#ShowAcct",
+                    this.WindowID);
+            strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl",
+                    this.WindowID);
+        } catch (final Exception ex) {
+            ex.printStackTrace();
+            log4j.error(ex);
+        }
+        final Stack<WindowTabsData> aux = this.tabs.get(Integer
+                .toString(this.level + 1));
+        if (aux == null)
+            return text.append("<td class=\"tabTabbarBackGround\"></td>")
+                    .toString();
+        text.append("<td class=\"tabBackGround\">\n");
+        text.append("  <table class=\"tabTable\"><tr>\n");
+        text
+                .append("    <td valign=\"top\"><span class=\"tabLeft\">&nbsp;</span></td>\n");
+        text
+                .append("    <td class=\"tabPaneBackGround\"><div class=\"marginLeft1\">\n");
+        boolean isFirst = true;
+        while (!aux.empty()) {
+            final WindowTabsData data = aux.pop();
+            if (!data.adTabId.equals(this.TabID) && strShowAcct.equals("N")
+                    && data.isinfotab.equals("Y"))
+                continue;
+            else if (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N")
+                    && data.istranslationtab.equals("Y"))
+                continue;
+            if (!isFirst)
+                text.append("<span class=\"tabSeparator\">&nbsp;</span>\n");
+            isFirst = false;
+            text.append("<span class=\"dojoTab").append(
+                    ((data.adTabId.equals(this.TabID) || data.isbreadcrumb
+                            .equals("Y")) ? " current" : "")).append("\">");
+            text.append("<div><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
+            if (readOnly)
+                text.append("return false;");
+            else
+                text.append(getUrlCommand(data.adTabId, data.name, Integer
+                        .valueOf(data.tablevel).intValue()));
+            text.append(
+                    "\" onMouseOver=\"return true;\" onMouseOut=\"return true;\"  id=\""
+                            + data.tabnameid + "\">").append(data.tabname)
+                    .append("</a></div></span>\n");
+        }
+        text
+                .append("    </div></td><td valign=\"top\"><span class=\"tabRight\">&nbsp;</span></td>\n");
+        text.append("  </tr></table>\n");
+        text.append("</td>\n");
+        return text.toString();
+    }
+
+    public String childTabs() {
+        return childTabs(false);
+    }
+
+    /*
+     * public String childTabs() { StringBuffer text = new StringBuffer(); if
+     * (this.tabs==null) return text.toString(); String strShowAcct = "N";
+     * String strShowTrl = "N"; try { strShowAcct =
+     * Utility.getContext(this.conn, this.vars, "#ShowAcct", this.WindowID);
+     * strShowTrl = Utility.getContext(this.conn, this.vars, "#ShowTrl",
+     * this.WindowID); } catch (Exception ex) { ex.printStackTrace();
+     * log4j.error(ex); } Stack<WindowTabsData> aux = (Stack<WindowTabsData>)
+     * this.tabs.get(Integer.toString(this.level+1)); if (aux==null) return
+     * text.toString();text.append(
+     * "<td class=\"tabPaneBackGround dojoTabContainerChild dojoTabLabels-bottom\">\n"
+     * ); text.append("<div>\n"); while (!aux.empty()) { WindowTabsData data =
+     * (WindowTabsData) aux.pop(); if (!data.adTabId.equals(this.TabID) &&
+     * strShowAcct.equals("N") && data.isinfotab.equals("Y")) continue; else if
+     * (!data.adTabId.equals(this.TabID) && strShowTrl.equals("N") &&
+     * data.istranslationtab.equals("Y")) continue;
+     * text.append("<span class=\"dojoTab"
+     * ).append(((data.adTabId.equals(this.TabID) ||
+     * data.isbreadcrumb.equals("Y"))?" current":"")).append("\">");
+     * text.append("<div><a class=\"dojoTabLink\" href=\"#\" onclick=\"");
+     * text.append(getUrlCommand(data.adTabId, data.name,
+     * Integer.valueOf(data.tablevel).intValue()));
+     * text.append("\" onMouseOver=\"return true;\" onMouseOut=\"return true;\">"
+     * ).append(data.tabname).append("</a></div></span>\n"); }
+     * text.append("</div>\n"); text.append("</td>\n"); return text.toString();
+     * }
+     */
+
+    /**
+     * Method to obtain the breadcrumb for this tab.
+     * 
+     * @return String with the HTML of the breadcrumb.
+     */
+    public String breadcrumb() {
+        final StringBuffer text = new StringBuffer();
+        if (this.breadcrumb == null || this.breadcrumb.empty())
+            return text.toString();
+        boolean isFirst = true;
+        try {
+            text.append("<span>").append(getMenuInfo()).append("</span>\n");
+            text.append("&nbsp;||&nbsp;\n");
+        } catch (final Exception ex) {
+            ex.printStackTrace();
+            log4j
+                    .error("Failed when trying to get parent menu element for breadcrumb");
+        }
+        while (!this.breadcrumb.empty()) {
+            final WindowTabsData data = this.breadcrumb.pop();
+            if (!isFirst)
+                text.append("&nbsp;&gt;&gt;&nbsp;\n");
+            else
+                isFirst = false;
+            if (!this.breadcrumb.empty()) {
+                text
+                        .append("<a class=\"Link\" onmouseover=\"return true;\" href=\"#\" onclick=\"");
+                text.append(getUrlCommand(data.adTabId, data.name, Integer
+                        .valueOf(data.tablevel).intValue()));
+                text.append("\" onmouseout=\"return true;\">").append(
+                        data.tabname).append("</a>\n");
+            } else
+                text.append(data.tabname).append("\n");
+        }
+        return text.toString();
+    }
+
+    /**
+     * Auxiliar method to get the click command for the elements.
+     * 
+     * @param _tabId
+     *            String with the id of the tab.
+     * @param _tabName
+     *            String with the tab's name.
+     * @param _level
+     *            Integer with the tab's level.
+     * @return String with the javascript command.
+     */
+    private String getUrlCommand(String _tabId, String _tabName, int _level) {
+        final StringBuffer text = new StringBuffer();
+        if (!_tabId.equals(this.TabID) && this.level + 1 >= _level) {
+            text.append("submitCommandForm('").append(
+                    ((this.level > _level) ? "DEFAULT" : "TAB")).append("', ");
+            text.append((editView) ? "isUserChanges" : "false").append(
+                    ", null, '");
+            text.append(FormatUtilities.replace(_tabName)).append(
+                    "_Relation.html', '_self', null, true);");
+        }
+        text.append("return false;");
+        return text.toString();
+    }
+}
\ No newline at end of file
--- a/src/org/openbravo/erpCommon/security/Login_F1.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html	Sat Nov 22 13:42:08 2008 +0000
@@ -60,7 +60,7 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if (!revisionControl('10173')) alert("Your browser's cache has outdated files. Please clean it and reload the page.");
+    if (!revisionControl('10423')) alert("Your browser's cache has outdated files. Please clean it and reload the page.");
   }
 
   function onResizeDo() {
--- a/src/org/openbravo/erpCommon/utility/NavigationBar.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/NavigationBar.java	Sat Nov 22 13:42:08 2008 +0000
@@ -11,87 +11,138 @@
  * 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-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
-*/
+ */
 package org.openbravo.erpCommon.utility;
 
+import org.apache.log4j.Logger;
 import org.openbravo.database.ConnectionProvider;
-import org.apache.log4j.Logger ;
 
 public class NavigationBar {
-  static Logger log4j = Logger.getLogger(NavigationBar.class);
-  ConnectionProvider conn;
-  String language = "en_US";
-  String servlet_action = "";
-  String window_name = "";
-  String base_direction = "";
-  String breadcrumb = "";
-  String window_type = "";
+    static Logger log4j = Logger.getLogger(NavigationBar.class);
+    ConnectionProvider conn;
+    String language = "en_US";
+    String servlet_action = "";
+    String window_name = "";
+    String base_direction = "";
+    String breadcrumb = "";
+    String window_type = "";
 
-  public NavigationBar(ConnectionProvider _conn, String _language, String _action, String _windowName, String _windowType, String _baseDirection, String _breadcrumb) {
-    this.conn = _conn;
-    this.language = _language;
-    this.servlet_action = _action;
-    this.window_name = _windowName;
-    this.base_direction = _baseDirection;
-    this.breadcrumb = _breadcrumb;
-    this.window_type = _windowType;
-  }
+    public NavigationBar(ConnectionProvider _conn, String _language,
+            String _action, String _windowName, String _windowType,
+            String _baseDirection, String _breadcrumb) {
+        this.conn = _conn;
+        this.language = _language;
+        this.servlet_action = _action;
+        this.window_name = _windowName;
+        this.base_direction = _baseDirection;
+        this.breadcrumb = _breadcrumb;
+        this.window_type = _windowType;
+    }
 
-  public String toString() {
-    StringBuffer toolbar = new StringBuffer();
-    toolbar.append("<table class=\"Main_ContentPane_NavBar\" id=\"tdtopNavButtons\">\n");
-    toolbar.append("  <tr class=\"Main_NavBar_bg\"><td></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_LeftButton_cell\">\n");
-    toolbar.append("    <a class=\"Main_NavBar_LeftButton\" href=\"#\" onclick=\"openLink('../secureApp/GoBack.html', 'appFrame')\" border=\"0\" onmouseover=\"window.status='");
-    String auxText = Utility.messageBD(conn, "GoBack", language);
-    toolbar.append(auxText);
-    toolbar.append("';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonBack\"><img src=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_NavBar_LeftButton_Icon Main_NavBar_LeftButton_Icon_back\" border=\"0\" alt=\"");
-    toolbar.append(auxText).append("\" title=\"").append(auxText).append("\"");
-    toolbar.append("/></a>\n");
-    toolbar.append("  </td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_separator_cell\"></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_LeftButton_cell\">\n");
-    toolbar.append("    <a class=\"Main_NavBar_LeftButton\" href=\"#\" onClick=\"submitCommandForm('DEFAULT', false, null, '").append(servlet_action);
-    toolbar.append("', '_self', null, true);return false;\" border=\"0\" onmouseover=\"window.status='");
-    auxText = Utility.messageBD(conn, "Refresh", language);
-    toolbar.append(auxText).append("';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonRefresh\"><img src=\"");
-    toolbar.append(base_direction).append("/images/blank.gif\" class=\"Main_NavBar_LeftButton_Icon Main_NavBar_LeftButton_Icon_refresh\" border=\"0\" alt=\"");
-    toolbar.append(auxText).append("\" title=\"").append(auxText).append("\"");
-    toolbar.append("></a>\n");
-    toolbar.append("  </td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_Breadcrumb_cell\"><span class=\"Main_NavBar_Breadcrumb\" id=\"paramBreadcrumb\">").append(breadcrumb).append("</span></td>\n");
-    toolbar.append("  <td></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_RightButton_cell\">\n");
-    toolbar.append("    <a class=\"Main_NavBar_RightButton\" href=\"#\" onclick=\"about();return false;\" border=\"0\" onmouseover=\"window.status='");
-    auxText = Utility.messageBD(conn, "About", language);
-    toolbar.append(auxText).append("';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonAbout\"><img src=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_NavBar_RightButton_Icon Main_NavBar_RightButton_Icon_about\" border=\"0\"");
-    toolbar.append(" alt=\"").append(auxText).append("\" title=\"").append(auxText).append("\"");
-    toolbar.append("></a>\n");
-    toolbar.append("  </td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_separator_cell_small\"></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_RightButton_cell\">\n");
-    toolbar.append("    <a class=\"Main_NavBar_RightButton\" href=\"#\" onclick=\"openHelp(");
-    if (window_type.equalsIgnoreCase("W")) toolbar.append("document.frmMain.inpwindowId.value");
-    else toolbar.append("null");
-    toolbar.append(", '../ad_help/DisplayHelp.html', 'HELP', false, null, null, '");
-    toolbar.append(window_type).append("', '").append(window_name);
-    toolbar.append("');return false;\" border=\"0\" onmouseover=\"window.status='");
-    auxText = Utility.messageBD(conn, "Help", language);
-    toolbar.append(auxText).append("';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonHelp\"><img src=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_NavBar_RightButton_Icon Main_NavBar_RightButton_Icon_help\" border=\"0\"");
-    toolbar.append(" alt=\"").append(auxText).append("\" title=\"").append(auxText).append("\"");
-    toolbar.append("></a>\n");
-    toolbar.append("  </td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_separator_cell\"></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_bg_logo_left\"></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_bg_logo\" width=\"1\" onclick=\"openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;\"><img src=\"").append(base_direction).append("/images/blank.gif\" alt=\"Openbravo\" title=\"Openbravo\" border=\"0\" id=\"openbravoLogo\" class=\"Main_NavBar_logo\"></td>\n");
-    toolbar.append("  <td class=\"Main_NavBar_bg_logo_right\"></td>\n");
-    toolbar.append("  <td></td>\n");
-    toolbar.append("  </tr>\n");
-    toolbar.append("</table>");
-    return toolbar.toString();
-  }
+    @Override
+    public String toString() {
+        final StringBuffer toolbar = new StringBuffer();
+        toolbar
+                .append("<TABLE class=\"Main_ContentPane_NavBar\" id=\"tdtopNavButtons\">\n");
+        toolbar.append("  <TR class=\"Main_NavBar_bg\"><TD></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_LeftButton_cell\">\n");
+        toolbar
+                .append("    <a class=\"Main_NavBar_LeftButton\" href=\"#\" onclick=\"openLink('../secureApp/GoBack.html', 'appFrame')\" border=\"0\" onmouseover=\"window.status='");
+        String auxText = Utility.messageBD(conn, "GoBack", language);
+        toolbar.append(auxText);
+        toolbar
+                .append(
+                        "';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonBack\"><IMG src=\"")
+                .append(base_direction)
+                .append(
+                        "/images/blank.gif\" class=\"Main_NavBar_LeftButton_Icon Main_NavBar_LeftButton_Icon_back\" border=\"0\" alt=\"");
+        toolbar.append(auxText).append("\" title=\"").append(auxText).append(
+                "\"");
+        toolbar.append("/></a>\n");
+        toolbar.append("  </TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_separator_cell\"></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_LeftButton_cell\">\n");
+        toolbar
+                .append(
+                        "    <a class=\"Main_NavBar_LeftButton\" href=\"#\" onClick=\"submitCommandForm('DEFAULT', false, null, '")
+                .append(servlet_action);
+        toolbar
+                .append("', '_self', null, true);return false;\" border=\"0\" onmouseover=\"window.status='");
+        auxText = Utility.messageBD(conn, "Refresh", language);
+        toolbar
+                .append(auxText)
+                .append(
+                        "';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonRefresh\"><IMG src=\"");
+        toolbar
+                .append(base_direction)
+                .append(
+                        "/images/blank.gif\" class=\"Main_NavBar_LeftButton_Icon Main_NavBar_LeftButton_Icon_refresh\" border=\"0\" alt=\"");
+        toolbar.append(auxText).append("\" title=\"").append(auxText).append(
+                "\"");
+        toolbar.append("></a>\n");
+        toolbar.append("  </TD>\n");
+        toolbar
+                .append(
+                        "  <TD class=\"Main_NavBar_Breadcrumb_cell\"><span class=\"Main_NavBar_Breadcrumb\" id=\"paramBreadcrumb\">")
+                .append(breadcrumb).append("</span></TD>\n");
+        toolbar.append("  <TD></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_RightButton_cell\">\n");
+        toolbar
+                .append("    <a class=\"Main_NavBar_RightButton\" href=\"#\" onclick=\"about();return false;\" border=\"0\" onmouseover=\"window.status='");
+        auxText = Utility.messageBD(conn, "About", language);
+        toolbar
+                .append(auxText)
+                .append(
+                        "';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonAbout\"><IMG src=\"")
+                .append(base_direction)
+                .append(
+                        "/images/blank.gif\" class=\"Main_NavBar_RightButton_Icon Main_NavBar_RightButton_Icon_about\" border=\"0\"");
+        toolbar.append(" alt=\"").append(auxText).append("\" title=\"").append(
+                auxText).append("\"");
+        toolbar.append("></a>\n");
+        toolbar.append("  </TD>\n");
+        toolbar
+                .append("  <TD class=\"Main_NavBar_separator_cell_small\"></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_RightButton_cell\">\n");
+        toolbar
+                .append("    <a class=\"Main_NavBar_RightButton\" href=\"#\" onclick=\"openHelp(");
+        if (window_type.equalsIgnoreCase("W"))
+            toolbar.append("document.frmMain.inpwindowId.value");
+        else
+            toolbar.append("null");
+        toolbar
+                .append(", '../ad_help/DisplayHelp.html', 'HELP', false, null, null, '");
+        toolbar.append(window_type).append("', '").append(window_name);
+        toolbar
+                .append("');return false;\" border=\"0\" onmouseover=\"window.status='");
+        auxText = Utility.messageBD(conn, "Help", language);
+        toolbar
+                .append(auxText)
+                .append(
+                        "';return true;\" onmouseout=\"window.status='';return true;\" id=\"buttonHelp\"><IMG src=\"")
+                .append(base_direction)
+                .append(
+                        "/images/blank.gif\" class=\"Main_NavBar_RightButton_Icon Main_NavBar_RightButton_Icon_help\" border=\"0\"");
+        toolbar.append(" alt=\"").append(auxText).append("\" title=\"").append(
+                auxText).append("\"");
+        toolbar.append("></a>\n");
+        toolbar.append("  </TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_separator_cell\"></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_bg_logo_left\"></TD>\n");
+        toolbar
+                .append(
+                        "  <TD class=\"Main_NavBar_bg_logo\" width=\"1\" onclick=\"openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;\"><IMG src=\"")
+                .append(base_direction)
+                .append(
+                        "/images/blank.gif\" alt=\"Openbravo\" title=\"Openbravo\" border=\"0\" id=\"openbravoLogo\" class=\"Main_NavBar_logo\"></TD>\n");
+        toolbar.append("  <TD class=\"Main_NavBar_bg_logo_right\"></TD>\n");
+        toolbar.append("  <TD></TD>\n");
+        toolbar.append("  </TR>\n");
+        toolbar.append("</TABLE>");
+        return toolbar.toString();
+    }
 }
--- a/src/org/openbravo/erpCommon/utility/OBError.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/OBError.java	Sat Nov 22 13:42:08 2008 +0000
@@ -58,6 +58,17 @@
     this.connectionAvailable = _data;
   }
 
+  public boolean isEmpty() {
+	  return (getTitle().equals("") && getMessage().equals("") && getType().equals(""));
+  }
+  
+  public void setError(OBError e) {
+	  setTitle(e.getTitle());
+	  setMessage(e.getMessage());
+	  setType(e.getType());
+	  setConnectionAvailable(e.isConnectionAvailable());
+  }
+  
   public boolean isConnectionAvailable() {
     return this.connectionAvailable;
   }
--- a/src/org/openbravo/erpCommon/utility/Utility.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/Utility.java	Sat Nov 22 13:42:08 2008 +0000
@@ -28,6 +28,7 @@
 import org.openbravo.utils.Replace;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.HashMap;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -41,7 +42,6 @@
 import java.sql.Connection;
 import javax.servlet.ServletException;
 import java.io.*;
-
 import org.apache.log4j.Logger ;
 
 /**
@@ -51,7 +51,31 @@
  */
 public class Utility {
   static Logger log4j = Logger.getLogger(Utility.class);
-
+  
+  private static List<String> autosaveExcludedPackages = null;
+  private static List<String> autosaveExcludedClasses = null;
+  
+  // List of excludes packages and classes from Autosave
+  // TODO: Define the autosave behavior at object level
+  static {
+	  autosaveExcludedPackages = new ArrayList<String>();
+      autosaveExcludedClasses = new ArrayList<String>();      
+      autosaveExcludedPackages.add("org.openbravo.erpCommon.info");
+      autosaveExcludedPackages.add("org.openbravo.erpCommon.ad_callouts");
+  }
+  
+  /**
+   * Checks if a class is excluded from the autosave process
+   * @param canonicalName
+   * @return True is the class is excluded or false if not.
+   */
+  public static boolean isExcludedFromAutoSave(String canonicalName){
+	  final int lastPos = canonicalName.lastIndexOf(".");
+	  final String packageName = canonicalName.substring(0, lastPos);
+	  return autosaveExcludedPackages.contains(packageName) ||
+	         autosaveExcludedClasses.contains(canonicalName);
+  }
+  
   /**
    * Checks if the references is a decimal number type.
    * 
@@ -385,16 +409,25 @@
   /**
    * Gets a default value.
    * 
-   * @param conn: Handler for the database connection.
-   * @param vars: Handler for the session info.
-   * @param columnname: String with the column name.
-   * @param context: String with the parameter.
-   * @param window: String with the window id.
-   * @param defaultValue: String with the default value.
+   * @param conn Handler for the database connection.
+   * @param vars  Handler for the session info.
+   * @param columnname  String with the column name.
+   * @param context String with the parameter.
+   * @param window String with the window id.
+   * @param defaultValueString with the default value.
+   * @param sessionData FieldProvider with the data stored in session
    * @return String with the value.
    */
-  public static String getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue) {
+  public static String getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue, FieldProvider sessionData) {
     if (columnname == null || columnname.equals("")) return "";
+    
+    if(sessionData != null) {
+    	final String sessionValue = (String) sessionData.getField(columnname);
+    	if(sessionValue != null) {
+    		return sessionValue;
+    	}    		
+    }
+    
     String defStr = getPreference(vars, columnname, window);
     if (!defStr.equals("")) return defStr;
 
@@ -417,6 +450,13 @@
   }
 
   /**
+   * Overloaded method for backwards compatibility
+   */
+  public static String getDefault(ConnectionProvider conn, VariablesSecureApp vars, String columnname, String context, String window, String defaultValue) { 
+	  return Utility.getDefault(conn, vars, columnname, context, window, defaultValue, null);
+  }
+  
+  /**
    * Returns a Vector<String> composed by the comma separated elements in String s 
    * @param s
    * @return
@@ -1328,6 +1368,23 @@
     String strBaseCurrencyId = UtilityData.getBaseCurrencyId(conn, strClientId);
     return strBaseCurrencyId;
   }
+
+  /**
+   * Build a JavaScript variable used for prompting a confirmation on changes
+   * @param vars Helper to access the user context
+   * @param windowId Identifier of the window
+   * @return A string containing a JavaScript variable to be used by the checkForChanges function (utils.js) 
+   */  
+  public static String getJSConfirmOnChanges(VariablesSecureApp vars, String windowId) {
+	  String jsString = "var confirmOnChanges = ";	  
+	  String showConfirmation = getPreference(vars, "ShowConfirmation", windowId);
+	
+	  if(showConfirmation == null || showConfirmation.equals(""))
+		  showConfirmation = vars.getSessionValue("#ShowConfirmation");
+	  jsString = jsString + (showConfirmation.equalsIgnoreCase("Y")?"true":"false") + ";";
+	  return jsString;
+  }
+
   
   /**
    * Trasnforms an ArrayList to a String comma separated
--- a/src/org/openbravo/erpCommon/utility/Utility_data.xsql	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/Utility_data.xsql	Sat Nov 22 13:42:08 2008 +0000
@@ -100,6 +100,18 @@
       </Sql>
       <Parameter name="adTabId"/>
    </SqlMethod>
+   <SqlMethod name="selectObjectMapping" type="preparedStatement" return="String" default="">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+        SELECT m.mappingname
+		  FROM ad_model_object o, ad_model_object_mapping m
+		 WHERE o.ad_model_object_id = m.ad_model_object_id
+		   AND o.ad_tab_id = ?
+		   AND o.isdefault = 'Y'
+		   AND m.isdefault = 'Y'
+      </Sql>
+      <Parameter name="adTabId"/>
+   </SqlMethod>
    <SqlMethod name="isTreeTab" type="preparedStatement" return="boolean" default="false">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
--- a/src/org/openbravo/erpCommon/utility/VerticalMenu.html	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/VerticalMenu.html	Sat Nov 22 13:42:08 2008 +0000
@@ -22,9 +22,8 @@
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>Menu</title>
     <link rel="stylesheet" type="text/css" href="../../../../../web/skins/Default/Openbravo_ERP_250.css" title="StyleGrid" id="paramCSS" />
-    <script language="JavaScript" type="text/javascript" id="paramDirectory">
-      var baseDirectory = "../../../../../web/";
-    </script>
+    <script language="JavaScript" type="text/javascript" id="paramDirectory">var baseDirectory = "../../../../../web/";</script>
+    <script language="JavaScript" type="text/javascript" id="paramAutosave">var autosave = false;</script>
     <script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>    
     <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
     <script language="JavaScript" src="../../../../../web/js/searchs.js" type="text/javascript"></script>
@@ -124,6 +123,27 @@
         openPopUp('../ad_forms/Registration.html', 'Registration', 500, 600);
       }
 
+      function validate(action, form, value) {
+         var appFrame = top.frames.appFrame;
+         var loc = appFrame.location.toString();
+         if( loc.indexOf('Home.html') != -1 || typeof(appFrame.depurar_validate_wrapper) == 'undefined' || typeof(appFrame.depurar) == 'undefined') {
+             return true;
+         }
+         return appFrame.depurar_validate_wrapper(action, form, value);
+      }
+
+      function getForm() {
+         var appForm = top.frames.appFrame.document.forms[0];
+         var loc = top.frames.appFrame.location.toString();
+         if(loc.indexOf('Home.html') != -1 || typeof(appForm) == 'undefined') {
+       	   return null;
+         }
+         
+         if(typeof(appForm.inpLastFieldChanged) == 'undefined' || appForm.inpLastFieldChanged.value == "") {
+           return null;
+         }
+         return appForm;
+      }
     </script>
   </head>
 
--- a/src/org/openbravo/erpCommon/utility/VerticalMenu.java	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/VerticalMenu.java	Sat Nov 22 13:42:08 2008 +0000
@@ -95,7 +95,8 @@
     xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
     xmlDocument.setParameter("theme", vars.getTheme());
     dataMenu = MenuData.select(this, vars.getLanguage(), vars.getRole(), data[0].parentId);
-    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
+    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";");
+    xmlDocument.setParameter("autosave", "var autosave = " + (vars.getSessionValue("#Autosave").equals("") || vars.getSessionValue("#Autosave").equalsIgnoreCase("N") ? "false" : "true") + ";");
     StringBuffer menu = new StringBuffer();
     menu.append(generarMenuVertical(dataMenu, strDireccion, "0", open));
     menu.append(generateMenuSearchs(vars, open));
@@ -179,7 +180,7 @@
           strText.append("\"");
           if (menuData[i].issummary.equals("N")) {
             strText.append(" id=\"child").append(strID).append("\"");
-            strText.append(" onclick=\"checkSelected('child").append(strID).append("');openLink('");
+            strText.append(" onclick=\"checkSelected('child").append(strID).append("');submitCommandForm('DEFAULT', " + (menuData[i].action.equals("F") ? "false" : "true") + ", getForm(),'");
             if (menuData[i].action.equals("L") || menuData[i].action.equals("I")) strText.append(menuData[i].url);
             else {
               strText.append(getUrlString(strDireccion, menuData[i].name, menuData[i].action, menuData[i].classname, menuData[i].mappingname, menuData[i].adWorkflowId, menuData[i].adTaskId, menuData[i].adProcessId, menuData[i].isexternalservice, menuData[i].serviceType));
@@ -190,7 +191,7 @@
             else strText.append(target);
             strText.append("'");
             if (menuData[i].action.equals("F")) strText.append(", 600, 600");
-            strText.append(");return false;\"");
+            strText.append(", false, "+ (menuData[i].action.equals("F") ? "false" : "true")+");return false;\"");
           } else {
             strText.append(" id=\"child").append(menuData[i].nodeId).append("\"");
           }
--- a/src/org/openbravo/erpCommon/utility/VerticalMenu.xml	Fri Nov 21 23:04:16 2008 +0000
+++ b/src/org/openbravo/erpCommon/utility/VerticalMenu.xml	Sat Nov 22 13:42:08 2008 +0000
@@ -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-2008 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -21,9 +21,10 @@
 	<template file="VerticalMenu.html"/>
 	<PARAMETER id="paramLanguage" name="language" default=""/>
 	<PARAMETER id="paramDirectory" name="directory"/>
+	<PARAMETER id="paramAutosave" name="autosave" default="var autosave = false;"/>
 	<PARAMETER id="paramMenu" name="menu"/>
-  <PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
-  <PARAMETER id="fieldUserName" name="userName"/>
-  <PARAMETER id="paramBody" name="popup" attribute="onload" replace="xx();"/>
+	<PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
+	<PARAMETER id="fieldUserName" name="userName"/>
+	<PARAMETER id="paramBody" name="popup" attribute="onload" replace="xx();"/>
 	<DISCARD id="discard"/>
 </REPORT>
--- a/web/js/appStatus.js	Fri Nov 21 23:04:16 2008 +0000
+++ b/web/js/appStatus.js	Sat Nov 22 13:42:08 2008 +0000
@@ -183,10 +183,12 @@
 
   if (value==true) {
     for (var i = 0; i < Buttons.length; i++) {
+      isUserChanges = true;
       enableToolBarButton(Buttons[i]);
     }
   } else if (value==false) {
     for (var i = 0; i < Buttons.length; i++) {
+      isUserChanges = false;
       disableToolBarButton(Buttons[i]);
     }
   }
--- a/web/js/messages.js	Fri Nov 21 23:04:16 2008 +0000
+++ b/web/js/messages.js	Sat Nov 22 13:42:08 2008 +0000
@@ -49,7 +49,8 @@
 			_language = LNG_POR_DEFECTO;
 		}
 	}
-  var total = arrMessages.length;
+	var arrMessages = top.appFrame.arrMessages;
+    var total = arrMessages.length;
 	for (var i=0;i<total;i++) {
 		if (arrMessages[i].language == _language)
 			if (arrMessages[i].message == index)
@@ -67,6 +68,7 @@
       _language = LNG_POR_DEFECTO;
     }
   }
+  var arrMessages = top.appFrame.arrMessages;
   var total = arrMessages.length;
 	for (var i=0;i<total;i++) {
 		if (arrMessages[i].language == _language)
@@ -77,6 +79,7 @@
 }
 
 function getType(index) {
+  var arrTypes = top.appFrame.arrTypes;
   var total = arrTypes.length;
 	for (var i=0;i<total;i++) {
 		if (arrTypes[i].id == index)
--- a/web/js/utils.js	Fri Nov 21 23:04:16 2008 +0000
+++ b/web/js/utils.js	Sat Nov 22 13:42:08 2008 +0000
@@ -52,11 +52,15 @@
 var pressedKeyCode = null;
 var isInputFile = false;
 
+var isPageLoading = true;
+var isUserChanges = false;
+
+
 /**
 * Return a number that would be checked at the Login screen to know if the file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '10173';
+  var number = '10423';
   return number;
 }
 
@@ -235,7 +239,7 @@
   if (form==null || !form) form = document.forms[0];
   if (form.inpLastFieldChanged==null) return false;
   if (field.type.toUpperCase().indexOf("SELECT")!=-1) {
-    if(field.selectedIndex==-1 || field.options[field.selectedIndex].defaultSelected || field.options[field.selectedIndex].value == "")
+    if(field.selectedIndex==-1 || field.options[field.selectedIndex].defaultSelected)
       return false;
   }
   form.inpLastFieldChanged.value = field.name;
@@ -243,19 +247,69 @@
 }
 
 /**
+ * Logs a User click to flag the document as changed
+ * @param hiddenInput HTML input part of the button UI
+ * @return
+ */
+function logClick(hiddenInput) {
+	isUserChanges = true;
+	if(hiddenInput != null) {
+		logChanges(hiddenInput);
+	}
+}
+
+/**
 * Check for changes in a Form. This function requires the inpLastFieldChanged field. Is a complementary function to {@link #setChangedField}
 * @param {Form} form Reference to a form where the inpLastFieldChanged is located.
 * @returns True if the inpLastFieldChanged has data and the user confirm the pop-up message. False if the field has no data or the user no confirm the pop-up message.
 * @type Boolean
 */
 function checkForChanges(form) {
-  if (form==null) form = document.forms[0];
-  if (inputValue(form.inpLastFieldChanged)!="") {
-    if (!showJSMessage(10)) return false;
-  }
-  return true;
+	if (form==null) form = top.appFrame.document.forms[0];
+	// backward compatibility
+	if(typeof(top.frameMenu.autosave) == 'undefined' || !top.frameMenu.autosave) {		
+		if (inputValue(form.inpLastFieldChanged)!="") {
+			if (!showJSMessage(26))
+				return false;
+		}
+		if(form.autosave) {
+			form.autosave.value = 'N';
+		}
+		return true;
+	}
+	else {
+		var promptConfirmation = typeof(top.appFrame.confirmOnChanges) == 'undefined' ? true : top.appFrame.confirmOnChanges;
+		var hasUserChanges = typeof(top.appFrame.isUserChanges) == 'undefined' ? false: top.appFrame.isUserChanges;
+		if (hasUserChanges) {
+			var autoSave = true;		
+			if (promptConfirmation)
+				autoSave = showJSMessage(25);
+			if (autoSave) {
+				if(form.autosave) {
+					form.autosave.value = 'Y';
+				}
+			}
+		}	
+		return true;
+	}	
 }
 
+/**
+ * Prompt a confirmation when an autosave process has failed. If the wants to
+ * stay in the page or navigate to the requested URL
+ * @param refererURL String URL to navigate to
+ * @return 
+ */
+function continueUserAction(requestURL) {
+	if(typeof(requestURL) == 'undefined') { 
+		return false;
+	}	
+	var continueAction = showJSMessage(26);
+	if(continueAction) {
+		submitCommandForm('DEFAULT', false, null, requestURL, 'appFrame', false, true);
+	}
+	return true;
+}
 
 /**
 * Function Description
@@ -2889,6 +2943,17 @@
 }
 
 /**
+* Sets the global variable 'isPageLoading' to true or false
+*/
+function setPageLoading(status) {
+  if (status==false) {
+    isPageLoading = false;
+  } else {
+    isPageLoading = true;
+  }
+}
+
+/**
 * Used on the onChange event for field changes logging. Requires a field named inpLastFieldChanged in the form.
 * @param {Object} field Reference to the field that will be logged. 
 * @returns True if everything goes right, false if the field does not exist or an error occurred. 
@@ -2896,6 +2961,7 @@
 * @see #setChangedField
 */
 function logChanges(field) {
+  if(!isUserChanges) return;
   changeToEditingMode();
   if (field==null || !field) return false;
   return setChangedField(field, field.form);
--- a/web/js/windowKeyboard.js	Fri Nov 21 23:04:16 2008 +0000
+++ b/web/js/windowKeyboard.js	Sat Nov 22 13:42:08 2008 +0000
@@ -175,6 +175,7 @@
     activateDefaultAction();
   } else {
     if(obj.tagName == 'SELECT') {
+      isUserChanges = true;
       selectedCombo = obj;
       isSelectedComboOpened = true;
       comboDefaultAction();