Author: jcompagner
Date: Wed Dec  1 11:46:07 2010
New Revision: 1040964

URL: http://svn.apache.org/viewvc?rev=1040964&view=rev
Log:
added the IIgnoreDisabledComponentBehavior tag interface for now and changed 
the BehaviorRequestTarget for that also throw an AbortException is the request 
is an ajax request

Added:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/behavior/IIgnoreDisabledComponentBehavior.java
Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/component/listener/BehaviorRequestTarget.java

Added: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/behavior/IIgnoreDisabledComponentBehavior.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/behavior/IIgnoreDisabledComponentBehavior.java?rev=1040964&view=auto
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/behavior/IIgnoreDisabledComponentBehavior.java
 (added)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/behavior/IIgnoreDisabledComponentBehavior.java
 Wed Dec  1 11:46:07 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.behavior;
+
+/**
+ * Interface that can be used to tag behaviors where response should be called 
on even if the
+ * component is disabled.
+ * 
+ * @author jcompagner
+ */
+public interface IIgnoreDisabledComponentBehavior extends IBehavior
+{
+
+}

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/component/listener/BehaviorRequestTarget.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/component/listener/BehaviorRequestTarget.java?rev=1040964&r1=1040963&r2=1040964&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/component/listener/BehaviorRequestTarget.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/component/listener/BehaviorRequestTarget.java
 Wed Dec  1 11:46:07 2010
@@ -18,13 +18,16 @@ package org.apache.wicket.request.target
 
 import java.util.List;
 
+import org.apache.wicket.AbortException;
 import org.apache.wicket.Component;
 import org.apache.wicket.Page;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.behavior.IBehavior;
 import org.apache.wicket.behavior.IBehaviorListener;
+import org.apache.wicket.behavior.IIgnoreDisabledComponentBehavior;
 import org.apache.wicket.protocol.http.PageExpiredException;
+import org.apache.wicket.protocol.http.WebRequest;
 import org.apache.wicket.request.RequestParameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -85,13 +88,6 @@ public class BehaviorRequestTarget exten
                // Get the IBehavior for the component based on the request 
parameters
                final Component component = getTarget();
 
-               if (!component.isVisibleInHierarchy() || 
!component.isEnabledInHierarchy())
-               {
-                       // ignore this request
-                       logger.warn("component not enabled or visible; ignoring 
call. Component: {}", component);
-                       return;
-               }
-
                final String id = getRequestParameters().getBehaviorId();
                if (id == null)
                {
@@ -124,6 +120,11 @@ public class BehaviorRequestTarget exten
                                        logger.warn(
                                                "behavior not enabled; ignoring 
call. behavior: {} at index: {} on component: {}",
                                                new Object[] { behavior, 
idAsInt, component });
+                                       if (requestCycle.getRequest() 
instanceof WebRequest &&
+                                               
((WebRequest)requestCycle.getRequest()).isAjax())
+                                       {
+                                               throw new AbortException();
+                                       }
                                        return;
                                }
 
@@ -138,6 +139,20 @@ public class BehaviorRequestTarget exten
                                "; Component: " + component.toString());
                }
 
+               if (!component.isVisibleInHierarchy() ||
+                       (!(behaviorListener instanceof 
IIgnoreDisabledComponentBehavior) && !component.isEnabledInHierarchy()))
+               {
+                       // ignore this request
+                       logger.warn("component not enabled or visible; ignoring 
call. Component: {}", component);
+                       if (requestCycle.getRequest() instanceof WebRequest &&
+                               
((WebRequest)requestCycle.getRequest()).isAjax())
+                       {
+                               throw new AbortException();
+                       }
+                       return;
+               }
+
+
                // Invoke the interface method
                behaviorListener.onRequest();
        }


Reply via email to