Author: jcompagner
Date: Wed Feb 21 12:49:29 2007
New Revision: 510198
URL: http://svn.apache.org/viewvc?view=rev&rev=510198
Log:
IBehavior.isEnabled()
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Component.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/SimpleAttributeModifier.java
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Component.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Component.java?view=diff&rev=510198&r1=510197&r2=510198
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Component.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Component.java
Wed Feb 21 12:49:29 2007
@@ -1498,13 +1498,16 @@
for (Iterator i = behaviors.iterator();
i.hasNext();)
{
IBehavior behavior =
(IBehavior)i.next();
- try
+ if
(isBehaviorAccepted(behavior))
{
-
behavior.exception(this, ex);
- }
- catch (Throwable ex2)
- {
- log.error("Error while
cleaning up after exception", ex2);
+ try
+ {
+
behavior.exception(this, ex);
+ }
+ catch (Throwable ex2)
+ {
+
log.error("Error while cleaning up after exception", ex2);
+ }
}
}
}
@@ -1740,7 +1743,10 @@
for (Iterator i = behaviors.iterator(); i.hasNext();)
{
IBehavior behavior = (IBehavior)i.next();
- behavior.detachModel(this);
+ if (isBehaviorAccepted(behavior))
+ {
+ behavior.detachModel(this);
+ }
}
}
}
@@ -2588,7 +2594,7 @@
return false;
}
- return true;
+ return behavior.isEnabled();
}
/**
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java?view=diff&rev=510198&r1=510197&r2=510198
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
Wed Feb 21 12:49:29 2007
@@ -148,4 +148,12 @@
public void renderHead(IHeaderResponse response)
{
}
+
+ /**
+ * @see wicket.behavior.IBehavior#isEnabled()
+ */
+ public boolean isEnabled()
+ {
+ return true;
+ }
}
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java?view=diff&rev=510198&r1=510197&r2=510198
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
Wed Feb 21 12:49:29 2007
@@ -120,4 +120,12 @@
* the component that has this behavior coupled
*/
void rendered(Component component);
+
+ /**
+ * Called when a components is rendering and wants to render this
+ * behavior. If false is returned this behavior will be ignored.
+ *
+ * @return true if this behaviour must be executed/rendered
+ */
+ boolean isEnabled();
}
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/SimpleAttributeModifier.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/SimpleAttributeModifier.java?view=diff&rev=510198&r1=510197&r2=510198
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/SimpleAttributeModifier.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/SimpleAttributeModifier.java
Wed Feb 21 12:49:29 2007
@@ -69,12 +69,4 @@
tag.getAttributes().put(attribute, value);
}
}
-
- /**
- * @return True to enable the modifier, false to disable
- */
- protected boolean isEnabled()
- {
- return true;
- }
}