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/18 09:49:18 UTC

svn commit: r423004 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/tableSuggest.js

Author: sharathreddy
Date: Tue Jul 18 00:49:18 2006
New Revision: 423004

URL: http://svn.apache.org/viewvc?rev=423004&view=rev
Log:
TableSuggestAjax Component: Made style options for the popup table, columnOut, columnHover attributes configurable. This functionality existed previously but was lost due to my changes to the component.

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
    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/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java?rev=423004&r1=423003&r2=423004&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java Tue Jul 18 00:49:18 2006
@@ -210,12 +210,15 @@
         String tableSuggestVar = "tableSuggest"+clientId.replace(':','_');
         String fieldNames = this.getFieldNames(tableSuggestAjax, context);
         String fieldNamesVar = tableSuggestVar + "_fieldNames";
+        String styleClassOptions = this.getStyleClassOptions(tableSuggestAjax);
+        String styleClassOptionsVar = tableSuggestVar + "_options";
         
         //doing ajax request and handling the response
         buf.append( "var " + fieldNamesVar + " = " + fieldNames + ";\n"
+                   + "var " + styleClassOptionsVar + " = " + styleClassOptions + ";\n"
                    + "var " + tableSuggestVar + " = new org_apache_myfaces_TableSuggest(\""+ ajaxUrl + "\", " 
                    + betweenKeyUp + ", " + startRequest + ", \"" + charset + "\", " + tableSuggestAjax.getAcceptValueToField().toString() 
-                   + ", " + fieldNamesVar + ");\n" 
+                   + ", " + fieldNamesVar + ", " + styleClassOptionsVar + ");\n" 
                    + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onkeyup\", function(evt) { " 
                    + tableSuggestVar + ".decideRequest(evt); });\n"  
                    + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onblur\", function(evt) { " 
@@ -539,6 +542,26 @@
         fieldNames.append("]");
         return fieldNames.toString();
     }   
+    
+    
+    //returns a javascript hashmap containing the style class settings
+    private String getStyleClassOptions(TableSuggestAjax tableSuggestAjax)
+    {
+        StringBuffer settings = new StringBuffer();
+        settings.append("{ ");
+        settings.append("tableStyleClass: "); 
+        settings.append("\"" + tableSuggestAjax.getTableStyleClass() + "\"");
+        settings.append(", ");
+        settings.append("columnOutClass: "); 
+        settings.append("\"" + tableSuggestAjax.getColumnOutClass() + "\"");
+        settings.append(", ");
+        settings.append("columnHoverClass: "); 
+        settings.append("\"" + tableSuggestAjax.getColumnHoverClass() + "\"");
+        settings.append(" }");
+        
+        return settings.toString();
+        
+    }
     
     
     

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=423004&r1=423003&r2=423004&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 Tue Jul 18 00:49:18 2006
@@ -20,7 +20,8 @@
                                            startChars,
                                            charset,
                                            acceptValueToField,
-                                           fieldNames)
+                                           fieldNames, 
+                                           styleClassOptions)
 {
     this.tablePagesCollection = new dojo.collections.ArrayList();
 
@@ -51,6 +52,12 @@
     this.scrollingRow = 0;
     this.fieldNames = fieldNames;
 
+    
+    this.tableStyleClass = styleClassOptions.tableStyleClass;
+    this.columnHoverClass = styleClassOptions.columnHoverClass;  
+    this.columnOutClass = styleClassOptions.columnOutClass;  
+    
+
     //puting the values from the choosen row into the fields
     org_apache_myfaces_TableSuggest.prototype.putValueToField = function(trElem)
     {
@@ -315,13 +322,17 @@
     org_apache_myfaces_TableSuggest.prototype.renderDropdown = function()
     {
         dojo.dom.removeChildren(this.popUp);
-
+        
         //if no data exists
-        if (this.data.length == 0) return;       
- 
+        if (this.data == null || this.data.length == 0) 
+        {
+            this.resetSettings();        
+            return;       
+        }
+        
         //create a table for the suggesting items
 	var suggestTable = document.createElement("table");
-        //suggestTable.setAttribute("class", "ajaxTable");
+        //suggestTable.setAttribute("class", this.tableStyleClass);
         suggestTable.className = "ajaxTable";
          
         var tbody = document.createElement("tbody");
@@ -340,18 +351,16 @@
             td.appendChild(tn);
         }
         	
+        var tableSuggestAjax = this;
+
         //adding the data items	
 	for (var i = 0; i < this.data.length; i++)
         {
             var columnsArray = this.data[i];
             tr = tbody.insertRow(tbody.rows.length);
-            //tr.setAttribute("onmouseover", "this.className='tableSuggestHover'");
-            //tr.setAttribute("onmouseout", "this.className='tableSuggestOut'");
-            //tr.setAttribute("id", "row" + (i + 1) + this.inputFieldId);
-            //tr.setAttribute("onclick", "tableSuggest" + this.inputFieldId.replace(':', '_') + ".putValueToField(this)");
-            
-            tr.onmouseover = function() { this.className= 'tableSuggestHover'; }
-            tr.onmouseout = function() { this.className= 'tableSuggestOut'; }
+                        
+            tr.onmouseover = function() { this.className = tableSuggestAjax.columnHoverClass; }
+            tr.onmouseout = function() { this.className= tableSuggestAjax.columnOutClass; }
             tr.id = "row" + (i + 1) + this.inputFieldId;
             var tableSuggest = this;
             tr.onclick = function(event) { 
@@ -527,14 +536,14 @@
 
     org_apache_myfaces_TableSuggest.prototype.addHoverClass = function(elem)
     {
-        dojo.html.removeClass(elem,"tableSuggestOut");
-        dojo.html.addClass(elem,"tableSuggestHover");
+        dojo.html.removeClass(elem, this.columnOutClass);
+        dojo.html.addClass(elem, this.columnHoverClass);
     };
 
     org_apache_myfaces_TableSuggest.prototype.addOutClass = function(elem)
     {
-        dojo.html.removeClass(elem,"tableSuggestHover");
-        dojo.html.addClass(elem,"tableSuggestOut");
+        dojo.html.removeClass(elem, this.columnHoverClass);
+        dojo.html.addClass(elem, this.columnOutClass);
     };
 
     org_apache_myfaces_TableSuggest.prototype.requestBetweenKeyUpEvents = function(millisBetweenKeyPress)