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 2010/07/03 13:12:14 UTC
svn commit: r960197 - in
/click/trunk/click/framework/src/org/apache/click/control: Button.java
Submit.java
Author: sabob
Date: Sat Jul 3 11:12:14 2010
New Revision: 960197
URL: http://svn.apache.org/viewvc?rev=960197&view=rev
Log:
button should handle ajax requests
Modified:
click/trunk/click/framework/src/org/apache/click/control/Button.java
click/trunk/click/framework/src/org/apache/click/control/Submit.java
Modified: click/trunk/click/framework/src/org/apache/click/control/Button.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Button.java?rev=960197&r1=960196&r2=960197&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Button.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Button.java Sat Jul 3 11:12:14 2010
@@ -18,6 +18,7 @@
*/
package org.apache.click.control;
+import org.apache.click.Context;
import org.apache.click.util.HtmlStringBuffer;
/**
@@ -141,14 +142,37 @@ public class Button extends Field {
// Public Methods --------------------------------------------------------
/**
- * Returns true, as buttons perform no server side logic.
+ * For non Ajax requests this method returns true, as buttons by default
+ * perform no server side logic. If the button is an Ajax target and a
+ * behavior is defined, the behavior action will be invoked.
*
* @see org.apache.click.control.Field#onProcess()
*
- * @return true
+ * @return true to continue Page event processing or false otherwise
*/
@Override
public boolean onProcess() {
+ Context context = getContext();
+
+ if (!context.isAjaxRequest()) {
+ return true;
+ }
+
+ if (isDisabled()) {
+ // Switch off disabled property if control has incoming request
+ // parameter. Normally this means the field was enabled via JS
+ if (context.hasRequestParameter(getName())) {
+ setDisabled(false);
+ } else {
+ // If field is disabled skip process event
+ return true;
+ }
+ }
+
+ if (context.hasRequestParameter(getName())) {
+ dispatchActionEvent();
+ }
+
return true;
}
Modified: click/trunk/click/framework/src/org/apache/click/control/Submit.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Submit.java?rev=960197&r1=960196&r2=960197&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Submit.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Submit.java Sat Jul 3 11:12:14 2010
@@ -194,8 +194,7 @@ public class Submit extends Button {
* Process the submit event and return true to continue event processing.
* <p/>
* If the submit button is clicked and a Control listener is defined, the
- * listener method will be invoked and its boolean return value will be
- * returned by this method.
+ * listener method will be invoked.
* <p/>
* Submit buttons will be processed after all the non Button Form Controls
* have been processed. Submit buttons will be processed in the order