You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/03/06 14:26:00 UTC

svn commit: r383529 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js

Author: mmarinschek
Date: Mon Mar  6 05:25:56 2006
New Revision: 383529

URL: http://svn.apache.org/viewcvs?rev=383529&view=rev
Log:
some changes to inputSuggestAjax in order to improve paginator feature

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java?rev=383529&r1=383528&r2=383529&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java Mon Mar  6 05:25:56 2006
@@ -127,8 +127,7 @@
         String clientId = component.getClientId(context);
         String actionURL = getActionUrl(context);
 
-        String urlWithValue = context.getExternalContext().encodeActionURL(actionURL+"?affectedAjaxComponent=" + clientId
-                              + "&" + clientId+"=");
+        String urlWithValue = context.getExternalContext().encodeActionURL(actionURL+"?affectedAjaxComponent=" + clientId);
 
         ResponseWriter out = context.getResponseWriter();
 
@@ -268,14 +267,14 @@
         buf.append(   "var "+tableSuggestVar+" = new org_apache_myfaces_TableSuggest();\n"
                     + "dojo.event.connect(dojo.byId(\"" + clientId + "\"), \"onkeyup\", function(evt)\n"
                     + "{\n"
-                    + "   if(evt.keyCode == 13)\n"
-                    + "   {  document.onclick();\n"
-                    + "      return;"
-                    + "   }"
+                    + "   if( (evt.keyCode == 13) || (evt.keyCode == 9) || (evt.keyCode == 8) ){\n"  //enter,tab, backspace
+                    + "      document.onclick();\n"
+                    + "      return;\n"
+                    + "   }\n"
                     + "   var handlerNode = dojo.byId(\"" + clientId + "\");\n"
                     + "   var popUp = dojo.byId(\"" + clientId+"_auto_complete"+"\");\n"
                     + "   var inputValue = handlerNode.value;\n"
-                    + "   var url = \""+ urlWithValue +"\"+inputValue;\n"
+                    + "   var url = \""+ urlWithValue +"&" + clientId+"=\"+inputValue;\n"
                     +     DojoUtils.createDebugStatement("onkeyup event occured, length is","inputValue.length")
                     +     DojoUtils.createDebugStatement("value is","inputValue")
                     + "   if(inputValue != \"\" ");

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js?rev=383529&r1=383528&r2=383529&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js Mon Mar  6 05:25:56 2006
@@ -1,7 +1,15 @@
 /**
- * Copyright 2006 The Apache Software Foundation.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
+C
+    pyright 2006 The Apache Software
+     Foundation.
+ *
+ * Licensed under the Apache Lic
+    ense, Version 2.0 (t
+h
+ "Li
+e
+se");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
@@ -14,13 +22,14 @@
  * limitations under the License.
  */
 
-//puting the values from the choosen row into the fields
+
 org_apache_myfaces_TableSuggest = function()
 {
     this.tablePagesCollection = new dojo.collections.ArrayList();
     this.firstHighlightedElem = null;
     this.actualHighlightedElem = null;
 
+    //puting the values from the choosen row into the fields
     org_apache_myfaces_TableSuggest.prototype.putValueToField = function(trElem)
     {
         var j = 0;
@@ -53,11 +62,9 @@
             if(!this.firstHighlightedElem)
             {
                 var firstOptionElem = this.getFirstRowElem(popUp);
-                dojo.html.removeClass(firstOptionElem,"tableSuggestOut");
-                dojo.html.addClass(firstOptionElem,"tableSuggestHover");
+                this.addHoverClass(firstOptionElem);
                 this.firstHighlightedElem = firstOptionElem;
                 this.actualHighlightedElem = firstOptionElem;
-                this.actualHighlightedElem.focus();
 
                 this.putValueToField(firstOptionElem);
             }
@@ -69,10 +76,8 @@
                 {
                     if(dojo.dom.getTagName(nextElem) == "tr")
                     {
-                        dojo.html.removeClass(this.actualHighlightedElem,"tableSuggestHover");
-                        dojo.html.addClass(this.actualHighlightedElem,"tableSuggestOut");
-                        dojo.html.removeClass(nextElem,"tableSuggestOut");
-                        dojo.html.addClass(nextElem,"tableSuggestHover");
+                        this.addOutClass(this.actualHighlightedElem);
+                        this.addHoverClass(nextElem);
                         this.actualHighlightedElem = nextElem
 
                         this.putValueToField(nextElem);
@@ -88,8 +93,10 @@
                         if(dojo.dom.getTagName(pageField) == "div")
                         {
                             this.nextPage(pageField);
-                            var firstOptionElem = this.getFirstRowElem(popUp);
-                            this.actualHighlightedElem = firstOptionElem;
+                            this.firstHighlightedElem = this.getFirstRowElem(popUp);
+                            this.addOutClass(this.actualHighlightedElem);
+                            this.addHoverClass(this.firstHighlightedElem);
+                            this.actualHighlightedElem = this.firstHighlightedElem;
                         }
                     }
                     else
@@ -105,10 +112,8 @@
             {
                 if(dojo.dom.getTagName(prevElem) == "tr")
                 {
-                    dojo.html.removeClass(this.actualHighlightedElem,"tableSuggestHover");
-                    dojo.html.addClass(this.actualHighlightedElem,"tableSuggestOut");
-                    dojo.html.removeClass(prevElem,"tableSuggestOut");
-                    dojo.html.addClass(prevElem,"tableSuggestHover");
+                    this.addOutClass(this.actualHighlightedElem);
+                    this.addHoverClass(prevElem);
                     this.actualHighlightedElem = prevElem;
 
                     this.putValueToField(prevElem);
@@ -121,8 +126,9 @@
                 if(table)
                 {
                     this.previousPage(table);
-                    var lastOptionElem = this.getLastRowElem(popUp);
-                    this.actualHighlightedElem = lastOptionElem;
+                    this.addOutClass(this.actualHighlightedElem);
+                    this.actualHighlightedElem = this.getLastRowElem(popUp);
+                    this.addHoverClass(this.actualHighlightedElem);
                 }
                 else
                     dojo.debug("could not move to next item in table, wrong item is");dojo.debug(nextElem);
@@ -130,6 +136,9 @@
         }
         else
         {
+            this.firstHighlightedElem = null;
+            this.actualHighlightedElem = null;
+
             dojo.io.bind
             ({
                url:  url,
@@ -175,7 +184,7 @@
                               collection.add(firstPage);
                               collection.add(firstPageField);
 
-                            }
+                            }     
                             else if(type == "error")
                             {
                               dojo.debug("error during response");
@@ -193,8 +202,8 @@
         var nextPage = this.tablePagesCollection.item(0);
         var nextPageField = this.tablePagesCollection.item(1);
 
-        this.tablePagesCollection.remove(0);
-        this.tablePagesCollection.remove(1);
+        this.tablePagesCollection.removeAt(0);
+        this.tablePagesCollection.removeAt(0);
 
         var thisPage = dojo.dom.prevElement(thisPageField);
 
@@ -209,40 +218,58 @@
         this.tablePagesCollection.add(thisPageField);
     };
 
-    org_apache_myfaces_TableSuggest.prototype.previousPage = function(thisTable)
+    org_apache_myfaces_TableSuggest.prototype.previousPage = function(thisPage)
     {
-        var prevPage = this.tablePagesCollection.item(this.tablePagesCollection.count+1);
-        var prevPageField = this.tablePagesCollection.item(this.tablePagesCollection.count);
+        var collLength = this.tablePagesCollection.count;
+        var prevPageField = this.tablePagesCollection.item(collLength-1);
+        var prevPage = this.tablePagesCollection.item(collLength-2);
 
-        this.tablePagesCollection.remove(this.tablePagesCollection.count+1);
-        this.tablePagesCollection.remove(this.tablePagesCollection.count);
+        this.tablePagesCollection.removeAt(collLength-1);
+        this.tablePagesCollection.removeAt(collLength-2);
 
-        var popUp = dojo.dom.getFirstAncestorByTag(thisTable, "div");
+        var popUp = dojo.dom.getFirstAncestorByTag(thisPage, "div");
 
         dojo.dom.removeChildren(popUp);
 
         dojo.dom.insertAtPosition(prevPage, popUp, "first");
         dojo.dom.insertAtPosition(prevPageField, popUp, "last");
 
-        this.tablePagesCollection.insert(this.tablePagesCollection.count,thisTable);
-        this.tablePagesCollection.insert(this.tablePagesCollection.count,dojo.dom.nextElement(thisTable));
+        var table = dojo.dom.firstElement(thisPage);
+        var thisPageField = dojo.dom.nextElement(table);
+        this.tablePagesCollection.insert(0,thisPageField);
+        this.tablePagesCollection.insert(0,thisPage);
+
     };
 
     org_apache_myfaces_TableSuggest.prototype.getFirstRowElem = function(popUp)
     {
         var table = dojo.dom.firstElement(popUp);
-        var tbody = table.childNodes[1];
-        var firstRowElem = dojo.dom.firstElement(tbody);
-
-        return firstRowElem;
+        if (table) {
+            var tbody = table.childNodes[1];
+            var firstRowElem = dojo.dom.firstElement(tbody);
+            return firstRowElem;
+        } else return null;
     };
 
     org_apache_myfaces_TableSuggest.prototype.getLastRowElem = function(popUp)
     {
         var table = dojo.dom.firstElement(popUp);
-        var tbody = table.childNodes[1];
-        var lastRowElem = dojo.dom.lastElement(tbody);
+        if(table) {
+            var tbody = table.childNodes[1];
+            var lastRowElem = dojo.dom.lastElement(tbody);
+            return lastRowElem;
+        }else return null;
+    };
+
+    org_apache_myfaces_TableSuggest.prototype.addHoverClass = function(elem)
+    {
+        dojo.html.removeClass(elem,"tableSuggestOut");
+        dojo.html.addClass(elem,"tableSuggestHover");
+    };
 
-        return lastRowElem;
+    org_apache_myfaces_TableSuggest.prototype.addOutClass = function(elem)
+    {
+        dojo.html.removeClass(elem,"tableSuggestHover");
+        dojo.html.addClass(elem,"tableSuggestOut");
     };
 }



Re: svn commit: r383529 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!

Our new license boilerplate?
> myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/inputsuggestajax/resource/tableSuggest.js Mon Mar  6 05:25:56 2006
> @@ -1,7 +1,15 @@
>  /**
> - * Copyright 2006 The Apache Software Foundation.
>   *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> +C
> +    pyright 2006 The Apache Software
> +     Foundation.
> + *
> + * Licensed under the Apache Lic
> +    ense, Version 2.0 (t
> +h
> + "Li
> +e
> +se");
>   
;-)
Mario