click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r770719 - in /incubator/click/branches/click-2.0.x: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
Date Fri, 01 May 2009 15:43:48 GMT
Author: sabob
Date: Fri May  1 15:43:48 2009
New Revision: 770719

URL: http://svn.apache.org/viewvc?rev=770719&view=rev
Log:
backport to 2.0.2. fixed remove bug in AutoCompleteTextField. CLK-546

Modified:
    incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
    incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java

Modified: incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html?rev=770719&r1=770718&r2=770719&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html Fri May 
1 15:43:48 2009
@@ -103,6 +103,12 @@
           [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-499">499</a>].
       </li>
       <li class="change">
+          Fixed a bug in AutoCompleteTextField where if the field was removed
+          from a Form, its JavaScript resources would still be rendered.
+          This issue was raised by Paul Zammit
+          [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-546">546</a>].
+      </li>
+      <li class="change">
           Fixed a bug in control.js which caused the addLoadEvent event queue to
           be reset if multiple control.js scripts are imported in the same page.
           This issue was raised by Adrian

Modified: incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java?rev=770719&r1=770718&r2=770719&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
(original)
+++ incubator/click/branches/click-2.0.x/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
Fri May  1 15:43:48 2009
@@ -221,6 +221,27 @@
     }
 
     /**
+     * @see org.apache.click.control.Field#setParent(Object)
+     *
+     * @param parent the parent of the Control
+     * @throws IllegalStateException if {@link #name} is not defined
+     * @throws IllegalArgumentException if the given parent instance is
+     * referencing <tt>this</tt> object: <tt>if (parent == this)</tt>
+     */
+    public void setParent(Object parent) {
+        if (parent == null) {
+            // If the field parent control is set to null (indicating the field
+            // is being removed), also remove the field from its parent page
+            Page page = getPage();
+            if (page != null) {
+                page.getControls().remove(this);
+                page.getModel().remove(getName());
+            }
+        }
+        super.setParent(parent);
+    }
+
+    /**
      * Return the HTML CSS and JavaScript includes.
      *
      * @see org.apache.click.Control#getHtmlImports()
@@ -266,12 +287,22 @@
      */
     public void onInit() {
         super.onInit();
+
+        Page page = getPage();
+        if (page == null) {
+            // If parent page is not reachable, exit early
+            return;
+        }
+
         // See whether control has been registered at Page level.
-        Object control = getPage().getModel().get(getName());
+        Object control = page.getModel().get(getName());
 
         // If not registered, then register control
         if (control == null) {
-            getPage().addControl(this);
+            // Ensure current parent control does not change
+            Object parent = getParent();
+            page.addControl(this);
+            setParent(parent);
 
         } else if (!(control instanceof AutoCompleteTextField)) {
             String message =



Mime
View raw message