You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sh...@apache.org on 2006/07/17 09:06:46 UTC

svn commit: r422644 - in /myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource: default/table_suggest.css tableSuggest.js

Author: sharathreddy
Date: Mon Jul 17 00:06:45 2006
New Revision: 422644

URL: http://svn.apache.org/viewvc?rev=422644&view=rev
Log:
TableSuggestAjax Component:
Fixed a bug: when the user uses 'Type Ahead' functionality to fill up the input field, and then tabs out of the field, the foreign-key fields were not being updated properly.

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css?rev=422644&r1=422643&r2=422644&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css Mon Jul 17 00:06:45 2006
@@ -7,7 +7,6 @@
     border-collapse:collapse;
     table-layout:auto;
     cursor:default;
-    cellpadding: 3;
     border: 1px solid black;
 }
 

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js?rev=422644&r1=422643&r2=422644&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js Mon Jul 17 00:06:45 2006
@@ -631,11 +631,17 @@
         
         var tableSuggest = this;
         this.hasFocus = false;
-                
+        
+        var selectedRecord = null;
+        
+        //the timeout function will validate the user's input
         this.blurTimer = setTimeout(function() { 
             
             tableSuggest.resetSettings();        
             if (tableSuggest.hasFocus) return;
+
+            //next time you tab into this field, you must save the old values
+            tableSuggest.saveOldValues = true;
             
             var inputValue = tableSuggest.inputField.value;
                         
@@ -645,9 +651,13 @@
             {
 	        var item = tableSuggest.data[i];
                 var primaryColumn = item[0];
-                if (inputValue == primaryColumn.label) return;
+                if (inputValue == primaryColumn.label) 
+                {
+                    tableSuggest.updateForeignKeyFields(item);
+                    return;
+                }
             }
-            //restore the original values of all the fields (including foreign-key fields)
+            //validation failed : restore the original values of all the fields (including foreign-key fields)
             for (var i = 0; i < tableSuggest.fieldNames.length; i++)
             {   
                 var fieldName = tableSuggest.fieldNames[i];
@@ -656,13 +666,32 @@
                 //tableSuggest.inputField.value = "";
                 //tableSuggest.inputField.focus();
             }
-            //next time you tab into this field, you must save the old values
-            tableSuggest.saveOldValues = true;
+            
       }, 500);
 
     }
-
-
+    
+    org_apache_myfaces_TableSuggest.prototype.updateForeignKeyFields = function(row) 
+    {
+        for (var i = 0; i < row.length; i++)
+        {
+            var column = row[i];
+            var fieldId, field;
+            
+            if (typeof column.forText != "undefined")
+            {
+                fieldId = column.forText;
+                field = dojo.byId(fieldId); 
+                field.value = column.label;
+            }
+            else {
+                fieldId = column.forValue;
+                field = dojo.byId(fieldId);     
+                field.value = column.value;
+            }
+        }
+    }
+    
     org_apache_myfaces_TableSuggest.prototype.handleKeyDown = function(evt)
     {
         var keyCode = evt.keyCode;