Author: ivaynberg Date: Mon Oct 30 10:27:45 2006 New Revision: 469222 URL: http://svn.apache.org/viewvc?view=rev&rev=469222 Log: wip: WICKET-23 introduced @OnBeforeRender, @OnAfterRender, deprecated old style methods
Added: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/AnnotationUtils.java incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAfterRender.java incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnBeforeRender.java Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java incubator/wicket/trunk/wicket/src/main/java/wicket/MarkupContainer.java incubator/wicket/trunk/wicket/src/main/java/wicket/Page.java incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAttach.java incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnDetach.java incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/FilePageStore.java incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebRequestCycle.java incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkablePageRequestTarget.java incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/PageRequestTarget.java incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ComponentResourceRequestTarget.java Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java Mon Oct 30 10:27:45 2006 @@ -19,8 +19,6 @@ package wicket; import java.io.Serializable; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -31,7 +29,10 @@ import org.apache.commons.logging.LogFactory; import wicket.ajax.AjaxRequestTarget; +import wicket.annot.AnnotationUtils; +import wicket.annot.OnAfterRender; import wicket.annot.OnAttach; +import wicket.annot.OnBeforeRender; import wicket.annot.OnDetach; import wicket.authorization.Action; import wicket.authorization.AuthorizationException; @@ -56,8 +57,6 @@ import wicket.util.convert.IConverter; import wicket.util.lang.Classes; import wicket.util.lang.Objects; -import wicket.util.lang.reflect.ClassOrder; -import wicket.util.lang.reflect.ReflectionUtils; import wicket.util.string.PrependingStringBuffer; import wicket.util.string.Strings; import wicket.util.value.IValueMap; @@ -795,6 +794,7 @@ if (getId().startsWith(AUTO_COMPONENT_PREFIX)) { internalAttach(); + AnnotationUtils.invokeOnAttachListeners(this); render(); } else @@ -1690,6 +1690,7 @@ { // Call implementation to render component onBeforeRender(); + AnnotationUtils.invokeOnBeforeRenderListeners(this); try { onRender(markupStream); @@ -1697,6 +1698,7 @@ finally { onAfterRender(); + AnnotationUtils.invokeOnAfterRenderListeners(this); } // Component has been rendered @@ -1781,6 +1783,7 @@ { ((IFeedback)component).updateFeedback(); component.internalAttach(); + AnnotationUtils.invokeOnAttachListeners(component); return IVisitor.CONTINUE_TRAVERSAL; } }); @@ -1817,11 +1820,13 @@ // Render the component and all its children onBeforeRender(); + AnnotationUtils.invokeOnBeforeRenderListeners(this); render(markupStream); } finally { onAfterRender(); + AnnotationUtils.invokeOnAfterRenderListeners(this); } } } @@ -2713,71 +2718,29 @@ * OVERRIDE. * * Called when a request begins. + * + * @deprecated - use [EMAIL PROTECTED] OnAttach} instead */ + @Deprecated protected void internalAttach() { onAttach(); internalOnAttach(); - - List<Method> listeners = ReflectionUtils.invocationChainForAnnotation(getClass(), - OnAttach.class, ClassOrder.SUPER_TO_SUB); - for (Method method : listeners) - { - invokeAnnotatedListenerMethod(method, OnAttach.class); - } - } - - /** - * Invokes a listener method - * - * @param method - * listener method - * @param annot - * annotation responsible for invocation - */ - private void invokeAnnotatedListenerMethod(Method method, Class<? extends Annotation> annot) - { - if (!method.getReturnType().equals(void.class) || method.getParameterTypes().length != 0) - { - throw new IllegalStateException("Method [[" + method.getName() - + "]] cannot be annotated with [[" + OnAttach.class.getSimpleName() - + "]] because it doesnt match signature [[void method()]]"); - } - try - { - if (!method.isAccessible()) - { - method.setAccessible(true); - } - method.invoke(this, LISTENER_ARGS); - } - catch (Exception e) - { - throw new WicketRuntimeException("Error while invoking listener method [[" - + method.getName() + "]] for [[" + annot.getClass().getSimpleName() - + "]] event", e); - } } - /** * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR * OVERRIDE. * * Called when a request ends. + * + * @deprecated - use [EMAIL PROTECTED] OnDetach} instead */ + @Deprecated protected void internalDetach() { internalOnDetach(); onDetach(); - - List<Method> listeners = ReflectionUtils.invocationChainForAnnotation(getClass(), - OnDetach.class, ClassOrder.SUB_TO_SUPER); - for (Method method : listeners) - { - invokeAnnotatedListenerMethod(method, OnAttach.class); - } - } /** @@ -2785,7 +2748,10 @@ * OVERRIDE. * * Called when a request begins. + * + * @deprecated - use [EMAIL PROTECTED] OnAttach} instead */ + @Deprecated protected void internalOnAttach() { } @@ -2795,7 +2761,10 @@ * OVERRIDE. * * Called when a request ends. + * + * @deprecated - use [EMAIL PROTECTED] OnDetach} instead */ + @Deprecated protected void internalOnDetach() { } @@ -2879,7 +2848,10 @@ /** * Called just after a component is rendered. + * + * @deprecated use [EMAIL PROTECTED] OnAfterRender} instead */ + @Deprecated protected void onAfterRender() { // Clear the component's markup cache and allow changes to locale, @@ -2895,14 +2867,20 @@ * this will be tightened in Wicket 1.3 when we will add the guarantee that * onAttach() be called before any framework use of a Component (in the * implementation of request targets). + * + * @deprecated - use [EMAIL PROTECTED] OnAttach} instead */ + @Deprecated protected void onAttach() { } /** * Called just before a component is rendered. + * + * @deprecated use [EMAIL PROTECTED] OnBeforeRender} instead */ + @Deprecated protected void onBeforeRender() { } @@ -2938,7 +2916,10 @@ * of this will be tightened in Wicket 1.3 when we will add the guarantee * that onDetach() be called after all framework use of a Component (in the * implementation of request targets). + * + * @deprecated - use [EMAIL PROTECTED] OnDetach} instead */ + @Deprecated protected void onDetach() { } Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/MarkupContainer.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/MarkupContainer.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/MarkupContainer.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/MarkupContainer.java Mon Oct 30 10:27:45 2006 @@ -28,6 +28,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import wicket.annot.AnnotationUtils; import wicket.feedback.IFeedback; import wicket.markup.ComponentTag; import wicket.markup.MarkupElement; @@ -109,7 +110,7 @@ /** The markup fragments from the associated file */ private transient MarkupFragment associatedMarkup; - + /** * Package scope constructor, only used by pages. * @@ -140,9 +141,10 @@ /** * Get the child markup fragment with the 'id'. * <p> - * Note that component paths don't work. + * Note that component paths don't work. * - * @param id The child component id + * @param id + * The child component id * @return MarkupFragment The childs markup */ public MarkupFragment getMarkupFragment(final String id) @@ -190,10 +192,10 @@ child.markupIndex = replaced.markupIndex; } - + return this; } - + /** * This method allows a component to be added by an auto-resolver such as * AutoComponentResolver or AutoLinkResolver. While the component is being @@ -361,6 +363,7 @@ try { super.internalAttach(); + AnnotationUtils.invokeOnAttachListeners(this); // Loop through child components final int size = children_size(); @@ -402,6 +405,7 @@ { // Handle end request for the container itself super.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(this); // Loop through child components final Iterator iter = iterator(); @@ -565,8 +569,8 @@ final MarkupStream associatedMarkupStream; try { - associatedMarkupStream = new MarkupStream(getAssociatedMarkup(true) - .getWicketFragment(openTagName, true)); + associatedMarkupStream = new MarkupStream(getAssociatedMarkup(true).getWicketFragment( + openTagName, true)); } catch (WicketRuntimeException ex) { @@ -812,11 +816,13 @@ { try { - this.associatedMarkup = getApplication().getMarkupCache().getMarkup(this, throwException); + this.associatedMarkup = getApplication().getMarkupCache().getMarkup(this, + throwException); } catch (MarkupException ex) { - // re-throw it. The exception contains already all the information + // re-throw it. The exception contains already all the + // information // required. throw ex; } @@ -832,26 +838,27 @@ + " Enable debug messages for wicket.util.resource to get a list of all filenames tried"), ex); } - + onAssociatedMarkupLoaded(this.associatedMarkup); } - + return this.associatedMarkup; } /** - * Components which whish to analyze the markup and automatically add Components - * to the MarkupConainer may sublcass this method. + * Components which whish to analyze the markup and automatically add + * Components to the MarkupConainer may sublcass this method. * <p> - * As the associated markup gets cached with the MarkupContainer, this method - * is guaranteed to be called just once. + * As the associated markup gets cached with the MarkupContainer, this + * method is guaranteed to be called just once. * - * @param markup The associated markup just loaded. + * @param markup + * The associated markup just loaded. */ protected void onAssociatedMarkupLoaded(final MarkupFragment markup) { } - + /** * Get the markup stream set on this container. * Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Page.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/Page.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/Page.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/Page.java Mon Oct 30 10:27:45 2006 @@ -25,6 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import wicket.annot.AnnotationUtils; import wicket.authorization.UnauthorizedActionException; import wicket.feedback.FeedbackMessages; import wicket.feedback.IFeedback; @@ -1221,6 +1222,7 @@ { ((IFeedback)component).updateFeedback(); component.internalAttach(); + AnnotationUtils.invokeOnAttachListeners(component); return IVisitor.CONTINUE_TRAVERSAL; } }); @@ -1239,7 +1241,7 @@ // or negative as a temporary boolean in the components, and when a // authorization exception is thrown it will block the rendering of this // page - + // first the page itself setRenderAllowed(isActionAuthorized(RENDER)); // children of the page @@ -1373,7 +1375,7 @@ { return getAssociatedMarkup(true); } - + /** * Get the string representation of this container. * Added: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/AnnotationUtils.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/annot/AnnotationUtils.java?view=auto&rev=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/annot/AnnotationUtils.java (added) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/annot/AnnotationUtils.java Mon Oct 30 10:27:45 2006 @@ -0,0 +1,181 @@ +/* + * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $ + * $Revision: 5004 $ + * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $ + * + * ============================================================================== + * Licensed 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 wicket.annot; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.List; + +import wicket.WicketRuntimeException; +import wicket.util.lang.reflect.ClassOrder; +import wicket.util.lang.reflect.ReflectionUtils; + +/** + * Annotation related utilities + * + * @author ivaynberg + */ +public class AnnotationUtils +{ + private AnnotationUtils() + { + } + + /** + * Invokes after render listeners on the specified object + * + * @see OnAfterRender + * + * @param object + */ + public static void invokeOnAfterRenderListeners(Object object) + { + invokeListeners(object, OnAfterRender.class, InvocationOrder.CLEANUP); + } + + + /** + * Invokes before render listeners on the specified object + * + * @see OnBeforeRender + * + * @param object + */ + public static void invokeOnBeforeRenderListeners(Object object) + { + invokeListeners(object, OnBeforeRender.class, InvocationOrder.SETUP); + } + + + /** + * Invokes detach listeners on the specified object + * + * @see OnDetach + * + * @param object + */ + public static void invokeOnDetachListeners(Object object) + { + invokeListeners(object, OnDetach.class, InvocationOrder.CLEANUP); + } + + + /** + * Invokes attach listeners on the specified object + * + * @see OnAttach + * + * @param object + */ + public static void invokeOnAttachListeners(Object object) + { + invokeListeners(object, OnAttach.class, InvocationOrder.SETUP); + } + + /** + * Invokes annotated listener methods on the object + * + * @param object + * @param annot + * @param order + */ + private static void invokeListeners(Object object, Class<? extends Annotation> annot, + InvocationOrder order) + { + List<Method> listeners = ReflectionUtils.invocationChainForAnnotation(object.getClass(), + annot, order.toClassOrder()); + for (Method method : listeners) + { + invokeAnnotatedListenerMethod(object, method, annot); + } + } + + /** empty object[] array used for invoking listener methods */ + private static final Object[] LISTENER_ARGS = new Object[] {}; + + /** + * Invokes a listener method + * + * @param object + * object whose listener will be invoked + * @param method + * listener method + * @param annot + * annotation responsible for invocation + */ + private static void invokeAnnotatedListenerMethod(Object object, Method method, + Class<? extends Annotation> annot) + { + if (!method.getReturnType().equals(void.class) || method.getParameterTypes().length != 0) + { + throw new IllegalStateException("Method [[" + method.getName() + + "]] cannot be annotated with [[" + OnAttach.class.getSimpleName() + + "]] because it doesnt match signature [[void method()]]"); + } + try + { + if (!method.isAccessible()) + { + method.setAccessible(true); + } + method.invoke(object, LISTENER_ARGS); + } + catch (Exception e) + { + throw new WicketRuntimeException("Error while invoking listener method [[" + + method.getName() + "]] for [[" + annot.getClass().getSimpleName() + + "]] event", e); + } + } + + /** + * Convinience wrapper around [EMAIL PROTECTED] ClassOrder} that makes it easier to + * figure out which class order should be used + * + * @author ivaynberg + */ + private static enum InvocationOrder { + /** + * represents order of initializing methods such as onAttach which are + * called with superclass to subclass order + */ + SETUP(ClassOrder.SUPER_TO_SUB), + + /** + * represents order of cleanup methods such as onDetach which are called + * with subclass to superclass order + */ + CLEANUP(ClassOrder.SUB_TO_SUPER); + + private InvocationOrder(ClassOrder order) + { + this.order = order; + } + + private final ClassOrder order; + + /** + * @return class order equivalent + */ + public ClassOrder toClassOrder() + { + return order; + } + } +} \ No newline at end of file Added: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAfterRender.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAfterRender.java?view=auto&rev=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAfterRender.java (added) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAfterRender.java Mon Oct 30 10:27:45 2006 @@ -0,0 +1,41 @@ +/* + * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $ + * $Revision: 5004 $ + * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $ + * + * ============================================================================== + * Licensed 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 wicket.annot; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Methods annotated with this annotation are invoked after the component's + * rendering begins. Methods must have signature <code>void ()</code>. + * + * Supported object types: + * <ul> + * <li> Component </li> + * </ul> + * + * @author ivaynberg + */ [EMAIL PROTECTED](ElementType.METHOD) [EMAIL PROTECTED](RetentionPolicy.RUNTIME) +public @interface OnAfterRender { + +} Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAttach.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAttach.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAttach.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnAttach.java Mon Oct 30 10:27:45 2006 @@ -25,7 +25,7 @@ /** * Methods annotated with this annotation are invoked when the object is - * attached by the framework. + * attached by the framework. Methods must have signature <code>void ()</code>. * * Objects are always attached once per request before any method on the object * is invoked by the framework during that request. Added: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnBeforeRender.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnBeforeRender.java?view=auto&rev=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnBeforeRender.java (added) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnBeforeRender.java Mon Oct 30 10:27:45 2006 @@ -0,0 +1,41 @@ +/* + * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $ + * $Revision: 5004 $ + * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $ + * + * ============================================================================== + * Licensed 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 wicket.annot; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Methods annotated with this annotation are invoked before the component's + * rendering begins. Methods must have signature <code>void ()</code>. + * + * Supported object types: + * <ul> + * <li> Component </li> + * </ul> + * + * @author ivaynberg + */ [EMAIL PROTECTED](ElementType.METHOD) [EMAIL PROTECTED](RetentionPolicy.RUNTIME) +public @interface OnBeforeRender { + +} Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnDetach.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnDetach.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnDetach.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/annot/OnDetach.java Mon Oct 30 10:27:45 2006 @@ -25,7 +25,7 @@ /** * Methods annotated with this annotation are invoked when the object is - * detached by the framework. + * detached by the framework. Methods must have signature <code>void ()</code>. * * Objects are always detached at the end of the request. This is the last * action the framework performs on the object. Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/FilePageStore.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/FilePageStore.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/FilePageStore.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/FilePageStore.java Mon Oct 30 10:27:45 2006 @@ -29,6 +29,7 @@ import wicket.Application; import wicket.Page; +import wicket.annot.AnnotationUtils; import wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore; import wicket.util.lang.Objects; @@ -47,8 +48,8 @@ */ public FilePageStore() { - workDir = (File)((WebApplication)Application.get()).getServletContext() - .getAttribute("javax.servlet.context.tempdir"); + workDir = (File)((WebApplication)Application.get()).getServletContext().getAttribute( + "javax.servlet.context.tempdir"); } /** @@ -150,6 +151,7 @@ // TODO check can this be called everytime at this place? Putting should // be called after the rendering so it should be ok. page.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(page); byte[] bytes = Objects.objectToByteArray(page); FileOutputStream fos = null; try Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java Mon Oct 30 10:27:45 2006 @@ -33,6 +33,7 @@ import wicket.Request; import wicket.Session; import wicket.WicketRuntimeException; +import wicket.annot.AnnotationUtils; import wicket.util.lang.Bytes; /** @@ -54,9 +55,10 @@ // session replication if (Application.get().getDebugSettings().getSerializeSessionAttributes()) { - if(value instanceof Page) + if (value instanceof Page) { ((Page)value).internalDetach(); + AnnotationUtils.invokeOnDetachListeners((Page)value); } String valueTypeName = (value != null ? value.getClass().getName() : "null"); try Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebRequestCycle.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebRequestCycle.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebRequestCycle.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebRequestCycle.java Mon Oct 30 10:27:45 2006 @@ -29,6 +29,7 @@ import wicket.Response; import wicket.RestartResponseAtInterceptPageException; import wicket.Session; +import wicket.annot.AnnotationUtils; import wicket.markup.html.pages.BrowserInfoPage; import wicket.protocol.http.request.WebClientInfo; import wicket.request.IRequestCycleProcessor; @@ -225,6 +226,7 @@ // Redirect page can touch its models already (via for example the // constructors) page.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(page); } if (redirectUrl == null) Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkablePageRequestTarget.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkablePageRequestTarget.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkablePageRequestTarget.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkablePageRequestTarget.java Mon Oct 30 10:27:45 2006 @@ -21,6 +21,7 @@ import wicket.Page; import wicket.PageParameters; import wicket.RequestCycle; +import wicket.annot.AnnotationUtils; import wicket.request.IRequestCycleProcessor; /** @@ -120,6 +121,7 @@ if (page != null) { page.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(page); } } Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/PageRequestTarget.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/PageRequestTarget.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/PageRequestTarget.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/PageRequestTarget.java Mon Oct 30 10:27:45 2006 @@ -20,6 +20,7 @@ import wicket.Page; import wicket.RequestCycle; +import wicket.annot.AnnotationUtils; /** * Default implementation of [EMAIL PROTECTED] IPageRequestTarget}. Target that denotes a @@ -83,6 +84,7 @@ public void detach(RequestCycle requestCycle) { page.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(page); } /** Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ComponentResourceRequestTarget.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ComponentResourceRequestTarget.java?view=diff&rev=469222&r1=469221&r2=469222 ============================================================================== --- incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ComponentResourceRequestTarget.java (original) +++ incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ComponentResourceRequestTarget.java Mon Oct 30 10:27:45 2006 @@ -23,6 +23,7 @@ import wicket.RequestCycle; import wicket.RequestListenerInterface; import wicket.WicketRuntimeException; +import wicket.annot.AnnotationUtils; /** * An implemenation of IRequestTarget that is used for the IResourceListener @@ -81,6 +82,7 @@ public void detach(RequestCycle requestCycle) { page.internalDetach(); + AnnotationUtils.invokeOnDetachListeners(page); } /**