click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r773994 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
Date Tue, 12 May 2009 17:30:33 GMT
Author: sabob
Date: Tue May 12 17:30:33 2009
New Revision: 773994

URL: http://svn.apache.org/viewvc?rev=773994&view=rev
Log:
improved AutoCompleteTextField headElements method

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java?rev=773994&r1=773993&r2=773994&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
Tue May 12 17:30:33 2009
@@ -280,17 +280,21 @@
             headElements.add(new JsImport("/click/prototype/prototype.js"));
             headElements.add(new JsImport("/click/prototype/effects.js"));
             headElements.add(new JsImport("/click/prototype/controls.js"));
+        }
 
-            String fieldId = getId();
+        // Note the addLoadEvent script is recreated and checked if it
+        // is contained in the headElement.
+        String fieldId = getId();
+        JsScript script = new JsScript();
+        script.setId(fieldId + "_autocomplete");
+        if (!headElements.contains(script)) {
             String contextPath = context.getRequest().getContextPath();
-
-            JsScript script = new JsScript();
-            script.setId(fieldId + "_autocomplete");
             HtmlStringBuffer buffer = new HtmlStringBuffer(150);
             buffer.append("addLoadEvent(function() { new Ajax.Autocompleter(");
             buffer.append("'").append(fieldId).append("'");
             buffer.append(",'").append(fieldId).append("_auto_complete_div'");
-            buffer.append(",'").append(contextPath).append(page.getPath()).append("'");
+            buffer.append(",'").append(contextPath).append(page.getPath()).append(
+                "'");
             buffer.append(",").append(getAutoCompleteOptions()).append(");})");
             script.setContent(buffer);
             headElements.add(script);



Mime
View raw message