You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/05/01 17:47:28 UTC

svn commit: r770728 - in /incubator/click/trunk/click: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/control/AutoCompleteTextField.java

Author: sabob
Date: Fri May  1 15:47:28 2009
New Revision: 770728

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

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

Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=770728&r1=770727&r2=770728&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Fri May  1 15:47:28 2009
@@ -238,6 +238,12 @@
           [<a target='_blank' href="https://issues.apache.org/jira/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/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=770728&r1=770727&r2=770728&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 Fri May  1 15:47:28 2009
@@ -215,6 +215,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 list of HEAD elements to be included in the page.
      * <p/>
      * This list of resources returned are:
@@ -303,12 +324,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 =