Author: ivaynberg Date: Fri Apr 27 23:19:41 2007 New Revision: 533307 URL: http://svn.apache.org/viewvc?view=rev&rev=533307 Log: renamed ibehavior.rendered to ibehavior.afterrender to better align with ibehavior.beforerender. added ibehavior.istemporary().
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IBehavior.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/TestDetachPage.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java Fri Apr 27 23:19:41 2007 @@ -180,7 +180,7 @@ * @param component * the model that initiates the detachement */ - public final void detachModel(Component component) + public final void detach(Component component) { if (replaceModel != null) { Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java Fri Apr 27 23:19:41 2007 @@ -1758,7 +1758,7 @@ } /** - * [EMAIL PROTECTED] IBehavior#rendered(Component)} Notify all behaviors that are + * [EMAIL PROTECTED] IBehavior#afterRender(Component)} Notify all behaviors that are * assigned to this component that the component has rendered. */ private void notifyBehaviorsComponentRendered() @@ -1771,7 +1771,7 @@ IBehavior behavior = (IBehavior)i.next(); if (isBehaviorAccepted(behavior)) { - behavior.rendered(this); + behavior.afterRender(this); } } } @@ -1814,7 +1814,16 @@ IBehavior behavior = (IBehavior)i.next(); if (isBehaviorAccepted(behavior)) { - behavior.detachModel(this); + /* + * TODO eelco: shouldnt we detach model always, accepted or + * not? what if this method returns true during render, but + * false here - something can go undetached + */ + behavior.detach(this); + } + if (behavior.isTemporary()) + { + i.remove(); } } } Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractBehavior.java Fri Apr 27 23:19:41 2007 @@ -22,8 +22,8 @@ import org.apache.wicket.markup.html.IHeaderResponse; /** - * Adapter implementation of [EMAIL PROTECTED] org.apache.wicket.behavior.IBehavior}. It is - * recommended to extend from this class instead of directly implementing + * Adapter implementation of [EMAIL PROTECTED] org.apache.wicket.behavior.IBehavior}. It + * is recommended to extend from this class instead of directly implementing * [EMAIL PROTECTED] org.apache.wicket.behavior.IBehavior} as this class has an extra clean * * @author Ralf Ebert @@ -63,11 +63,11 @@ } /** - * @see org.apache.wicket.behavior.IBehavior#detachModel(Component) + * @see org.apache.wicket.behavior.IBehavior#detach(Component) */ - public void detachModel(Component component) + public void detach(Component component) { - + } /** @@ -85,7 +85,7 @@ cleanup(); } } - + /** * @see org.apache.wicket.behavior.IBehavior#getStatelessHint(org.apache.wicket.Component) */ @@ -128,9 +128,9 @@ } /** - * @see org.apache.wicket.behavior.IBehavior#rendered(org.apache.wicket.Component) + * @see org.apache.wicket.behavior.IBehavior#afterRender(org.apache.wicket.Component) */ - public final void rendered(final Component component) + public final void afterRender(final Component component) { try { @@ -141,19 +141,27 @@ cleanup(); } } - + /** * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse) */ public void renderHead(IHeaderResponse response) { } - + /** * @see org.apache.wicket.behavior.IBehavior#isEnabled(Component) */ public boolean isEnabled(Component component) { return true; + } + + /** + * @see org.apache.wicket.behavior.IBehavior#isTemporary() + */ + public boolean isTemporary() + { + return false; } } Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IBehavior.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IBehavior.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IBehavior.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IBehavior.java Fri Apr 27 23:19:41 2007 @@ -30,8 +30,8 @@ * component. * <p> * It is recommended that you extend from - * [EMAIL PROTECTED] org.apache.wicket.behavior.AbstractBehavior} instead of directly implementing - * this interface. + * [EMAIL PROTECTED] org.apache.wicket.behavior.AbstractBehavior} instead of directly + * implementing this interface. * </p> * * @see org.apache.wicket.behavior.IBehaviorListener @@ -41,6 +41,7 @@ * * @author Ralf Ebert * @author Eelco Hillenius + * @author Igor Vaynberg (ivaynberg) */ public interface IBehavior extends IClusterable { @@ -53,6 +54,14 @@ void beforeRender(Component component); /** + * Called when a component that has this behavior coupled was rendered. + * + * @param component + * the component that has this behavior coupled + */ + void afterRender(Component component); + + /** * Bind this handler to the given component. This method is called by the * host component immediately after this behavior is added to it. This * method is useful if you need to do initialization based on the component @@ -67,22 +76,19 @@ void bind(Component component); /** - * Provides for the ability to detach any models this behavior has. This - * method is called by the components which have this behavior attached to - * them when they are detaching their models themselves (ie after - * rendering). Note that if you share a behavior between components, this - * method is called multiple times. + * Allows the behavior to detach any state it has attached during request + * processing. * * @param component * the component that initiates the detachement of this behavior */ - void detachModel(Component component); + void detach(Component component); /** * In case an unexpected exception happened anywhere between * onComponentTag() and rendered(), onException() will be called for any * behavior. Typically, if you clean up resources in - * [EMAIL PROTECTED] #rendered(Component)}, you should do the same in the + * [EMAIL PROTECTED] #afterRender(Component)}, you should do the same in the * implementation of this method. * * @param component @@ -97,8 +103,8 @@ * This method returns false if the behaviour generates a callback url (for * example ajax behaviours) * - * @param component - * the component that has this behavior coupled. + * @param component + * the component that has this behavior coupled. * * @return boolean true or false. */ @@ -127,10 +133,12 @@ void onComponentTag(Component component, ComponentTag tag); /** - * Called when a component that has this behavior coupled was rendered. + * Specifies whether or not this behavior is temporary. Temporary behaviors + * are removed at the end of request. Such behaviors are useful for + * modifying component rendering only when it renders next. Usecases include + * javascript effects, initial clientside dom setup, etc. * - * @param component - * the component that has this behavior coupled + * @return true if this behavior is temporary */ - void rendered(Component component); + boolean isTemporary(); } Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/StringHeaderContributor.java Fri Apr 27 23:19:41 2007 @@ -157,9 +157,9 @@ } /** - * @see org.apache.wicket.behavior.AbstractBehavior#detachModel(org.apache.wicket.Component) + * @see org.apache.wicket.behavior.AbstractBehavior#detach(org.apache.wicket.Component) */ - public void detachModel(Component component) + public void detach(Component component) { contributor.contribution.detach(); } Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/TestDetachPage.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/TestDetachPage.java?view=diff&rev=533307&r1=533306&r2=533307 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/TestDetachPage.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/TestDetachPage.java Fri Apr 27 23:19:41 2007 @@ -105,10 +105,10 @@ /** for serialization. */ private static final long serialVersionUID = 1L; - public void detachModel(Component component) + public void detach(Component component) { nrAjaxBehaviorDetachModelCalls++; - super.detachModel(component); + super.detach(component); } protected void onEvent(AjaxRequestTarget target)