click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r761667 - in /incubator/click/trunk/click: extras/src/org/apache/click/extras/control/ framework/src/org/apache/click/control/
Date Fri, 03 Apr 2009 13:24:02 GMT
Author: sabob
Date: Fri Apr  3 13:24:02 2009
New Revision: 761667

URL: http://svn.apache.org/viewvc?rev=761667&view=rev
Log:
rolled back CLK-508

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AutoCompleteTextField.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/ActionButton.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/Field.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/Form.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/Radio.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java
    incubator/click/trunk/click/framework/src/org/apache/click/control/Submit.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
Fri Apr  3 13:24:02 2009
@@ -257,13 +257,9 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        boolean continueProcessing = true;
-
-        if (canProcess()) {
-            continueProcessing = super.onProcess();
-            if (!container.onProcess()) {
-                continueProcessing = false;
-            }
+        boolean continueProcessing = super.onProcess();
+        if (!container.onProcess()) {
+            continueProcessing = false;
         }
         return continueProcessing;
     }

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=761667&r1=761666&r2=761667&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 Apr  3 13:24:02 2009
@@ -216,6 +216,15 @@
 
     /**
      * Return the list of HEAD elements to be included in the page.
+     * <p/>
+     * This list of resources returned are:
+     * <ul>
+     * <li>/click/extras-control.css</li>
+     * <li>/click/control.js</li>
+     * <li>/click/prototype/prototype.js</li>
+     * <li>/click/prototype/effects.js</li>
+     * <li>/click/prototype/controls.js</li>
+     * </ul>
      *
      * @see org.apache.click.Control#getHeadElements()
      *
@@ -287,6 +296,31 @@
     // --------------------------------------------------------- Event Handlers
 
     /**
+     * Register the field with the parent page to intercept POST autocompletion
+     * requests.
+     *
+     * @see org.apache.click.Control#onInit()
+     */
+    public void onInit() {
+        super.onInit();
+        // See whether control has been registered at Page level.
+        Object control = getPage().getModel().get(getName());
+
+        // If not registered, then register control
+        if (control == null) {
+            getPage().addControl(this);
+
+        } else if (!(control instanceof AutoCompleteTextField)) {
+            String message =
+                "Non AutoCompleteTextField object '"
+                + control.getClass().toString()
+                + "' already registered in Page as: "
+                + getName();
+            throw new IllegalStateException(message);
+        }
+    }
+
+    /**
      * Process the page request and if an auto completion POST request then
      * render an list of suggested values.
      *
@@ -296,16 +330,18 @@
      */
     public boolean onProcess() {
         Context context = getContext();
-        // If an auto complete POST request, render suggestion list,
-        // otherwise continue as normal
-        if (getForm().isFormSubmission()) {
-            return super.onProcess();
-        } else {
-            String criteria = context.getRequestParameter(getName());
-            if (criteria != null) {
-                List autoCompleteList = getAutoCompleteList(criteria);
-                renderAutoCompleteList(autoCompleteList);
-                return false;
+        if (context.isPost()) {
+            // If an auto complete POST request then render suggested list,
+            // otherwise continue as normal
+            if (getForm().isFormSubmission()) {
+                return super.onProcess();
+            } else if (context.isAjaxRequest()) {
+                String criteria = context.getRequestParameter(getName());
+                if (criteria != null) {
+                    List autoCompleteList = getAutoCompleteList(criteria);
+                    renderAutoCompleteList(autoCompleteList);
+                    return false;
+                }
             }
         }
         return true;

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/ActionButton.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/ActionButton.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/ActionButton.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/ActionButton.java Fri
Apr  3 13:24:02 2009
@@ -490,12 +490,10 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        if (canProcess()) {
-            bindRequestValue();
+        bindRequestValue();
 
-            if (isClicked()) {
-                registerActionEvent();
-            }
+        if (isClicked()) {
+            registerActionEvent();
         }
         return true;
     }

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/Field.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/Field.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/Field.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/Field.java Fri Apr
 3 13:24:02 2009
@@ -895,15 +895,14 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        if (canProcess()) {
-            bindRequestValue();
+        bindRequestValue();
 
-            if (getValidate()) {
-                validate();
-            }
-
-            registerActionEvent();
+        if (getValidate()) {
+            validate();
         }
+
+        registerActionEvent();
+
         return true;
     }
 
@@ -921,54 +920,6 @@
     // ------------------------------------------------------ Protected Methods
 
     /**
-     * Returns true if the Field's onProcess event handler should be invoked,
-     * false otherwise.
-     * <p/>
-     * By default this method will return true if:
-     * <ul>
-     * <li>the Field's Form is submitted. This method invokes
-     * {@link Form#isFormSubmission()} to check if the Form is submitted or not
-     * </li>
-     * <li>the method {@link #getForm()} returns null, meaning the Field is
-     * not added to a Form but to a different Container.
-     * </li>
-     * <li>the Field is added directly to the Page, for example through
-     * autobinding
-     * </li>
-     * <li>the request is an Ajax request. This method invoked
-     * {@link org.apache.click.Context#isAjaxRequest()} to check if the request
-     * is an Ajax request or not
-     * </li>
-     * </ul>
-     *
-     * @return true if the Field's onProcess event handler should be invoked,
-     * false otherwise
-     */
-    protected boolean canProcess() {
-        // This method should return true for Ajax requests. Otherwise,
-        // if the Form is not submitted, an Ajax request targeting this field
-        // won't be processed.
-        if (getContext().isAjaxRequest()) {
-            return true;
-        }
-
-        Form form = getForm();
-        if (form != null) {
-
-            // If the Field was added to both Form and Page (normally via
-            // autobinding), return true in order for the field to be processed
-            Page page = getPage();
-            if (page != null && page.getModel().containsKey(getName())) {
-                return true;
-            }
-
-            return form.isFormSubmission();
-        } else {
-            return true;
-        }
-    }
-
-    /**
      * Return a normalized label for display in error messages.
      * <p/>
      * The error label is a normalized version of {@link #getLabel()}.

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/Form.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/Form.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/Form.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/Form.java Fri Apr 
3 13:24:02 2009
@@ -626,9 +626,6 @@
     /** The label &lt;td&gt; "style" attribute value. */
     protected String labelStyle;
 
-    /** The form submission flag. */
-    protected Boolean formSubmission;
-
     // ----------------------------------------------------------- Constructors
 
     /**
@@ -1128,20 +1125,14 @@
      * @return true if the page request is a submission from this form
      */
     public boolean isFormSubmission() {
-        if (formSubmission != null) {
-            return formSubmission.booleanValue();
-        }
-
         Context context = getContext();
         String requestMethod = context.getRequest().getMethod();
 
-        if (getMethod().equalsIgnoreCase(requestMethod)
-            && getName().equals(context.getRequestParameter(FORM_NAME))) {
-            formSubmission = Boolean.TRUE;
-        } else {
-            formSubmission = Boolean.FALSE;
+        if (!getMethod().equalsIgnoreCase(requestMethod)) {
+            return false;
         }
-        return formSubmission.booleanValue();
+
+        return getName().equals(context.getRequestParameter(FORM_NAME));
     }
 
     /**
@@ -1750,20 +1741,19 @@
         }
 
         boolean continueProcessing = true;
+        if (isFormSubmission()) {
 
-        for (int i = 0, size = getControls().size(); i < size; i++) {
-            Control control = (Control) getControls().get(i);
-            String controlName = control.getName();
-            if (controlName == null ||
-                !controlName.startsWith(Form.SUBMIT_CHECK)) {
+            for (int i = 0, size = getControls().size(); i < size; i++) {
+                Control control = (Control) getControls().get(i);
+                String controlName = control.getName();
+                if (controlName == null || !controlName.startsWith(Form.SUBMIT_CHECK)) {
 
-                if (!control.onProcess()) {
-                    continueProcessing = false;
+                    if (!control.onProcess()) {
+                        continueProcessing = false;
+                    }
                 }
             }
-        }
 
-        if (isFormSubmission()) {
             registerActionEvent();
         }
 
@@ -1779,7 +1769,6 @@
     public void onDestroy() {
         super.onDestroy();
 
-        formSubmission = null;
         setError(null);
     }
 

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/Radio.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/Radio.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/Radio.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/Radio.java Fri Apr
 3 13:24:02 2009
@@ -313,12 +313,10 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        if (canProcess()) {
-            bindRequestValue();
+        bindRequestValue();
 
-            if (isChecked()) {
-                registerActionEvent();
-            }
+        if (isChecked()) {
+            registerActionEvent();
         }
         return true;
     }

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/RadioGroup.java Fri
Apr  3 13:24:02 2009
@@ -276,7 +276,7 @@
         if (objects.isEmpty()) {
             return;
         }
- 
+
         Map cache = new HashMap();
 
         for (Iterator i = objects.iterator(); i.hasNext();) {
@@ -422,24 +422,22 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        boolean continueProcessing = true;
-
-        if (canProcess()) {
-            bindRequestValue();
-
-            for (int i = 0, size = getRadioList().size(); i < size; i++) {
-                Radio radio = (Radio) getRadioList().get(i);
-                if (!radio.onProcess()) {
-                    continueProcessing = false;
-                }
-            }
+        bindRequestValue();
 
-            if (getValidate()) {
-                validate();
+        boolean continueProcessing = true;
+        for (int i = 0, size = getRadioList().size(); i < size; i++) {
+            Radio radio = (Radio) getRadioList().get(i);
+            if (!radio.onProcess()) {
+                continueProcessing = false;
             }
+        }
 
-            registerActionEvent();
+        if (getValidate()) {
+            validate();
         }
+
+        registerActionEvent();
+
         return continueProcessing;
     }
 

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/Submit.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/Submit.java?rev=761667&r1=761666&r2=761667&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/Submit.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/Submit.java Fri Apr
 3 13:24:02 2009
@@ -202,12 +202,10 @@
      * @return true to continue Page event processing or false otherwise
      */
     public boolean onProcess() {
-        if (canProcess()) {
-            bindRequestValue();
+        bindRequestValue();
 
-            if (isClicked()) {
-                registerActionEvent();
-            }
+        if (isClicked()) {
+            registerActionEvent();
         }
 
         return true;



Mime
View raw message