Author: knopp Date: Wed Jun 6 03:00:29 2007 New Revision: 544789 URL: http://svn.apache.org/viewvc?view=rev&rev=544789 Log: (empty)
Added: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnAfterRenderListener.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnBeforeRenderListener.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java?view=diff&rev=544789&r1=544788&r2=544789 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java Wed Jun 6 03:00:29 2007 @@ -29,6 +29,8 @@ import java.util.Properties; import org.apache.wicket.application.IComponentInstantiationListener; +import org.apache.wicket.application.IComponentOnAfterRenderListener; +import org.apache.wicket.application.IComponentOnBeforeRenderListener; import org.apache.wicket.markup.MarkupCache; import org.apache.wicket.markup.html.image.resource.DefaultButtonImageResourceFactory; import org.apache.wicket.markup.parser.filter.RelativePathPrefixHandler; @@ -894,6 +896,116 @@ for (int i = 0; i < len; i++) { componentInstantiationListeners[i].onInstantiation(component); + } + } + + private List componentOnBeforeRenderListeners = null; + + /** + * Adds an [EMAIL PROTECTED] IComponentOnBeforeRenderListener}. This method should typicaly only + * be called during application startup; it is not thread safe. + * + * @param listener + */ + final public void addComponentOnBeforeRenderListener(IComponentOnBeforeRenderListener listener) + { + if (componentOnBeforeRenderListeners == null) + { + componentOnBeforeRenderListeners = new ArrayList(); + } + + if (componentOnBeforeRenderListeners.contains(listener) == false) + { + componentOnBeforeRenderListeners.add(listener); + } + } + + /** + * Removes an [EMAIL PROTECTED] IComponentOnBeforeRenderListener}. + * + * @param listener + */ + final public void removeComponentOnBeforeRenderListener(IComponentOnBeforeRenderListener listener) + { + if (componentOnBeforeRenderListeners != null) + { + componentOnBeforeRenderListeners.remove(listener); + if (componentOnBeforeRenderListeners.isEmpty()) + { + componentOnBeforeRenderListeners = null; + } + } + } + + /** + * Notifies the [EMAIL PROTECTED] IComponentOnBeforeRenderListener}s. + * + * @param component + */ + final void notifyComponentOnBeforeRenderListeners(Component component) + { + if (componentOnBeforeRenderListeners != null) + { + for (Iterator i = componentOnBeforeRenderListeners.iterator(); i.hasNext();) + { + IComponentOnBeforeRenderListener listener = (IComponentOnBeforeRenderListener) i.next(); + listener.onBeforeRender(component); + } + } + } + + private List componentOnAfterRenderListeners = null; + + /** + * Adds an [EMAIL PROTECTED] IComponentOnAfterRenderListener}. This method should typicaly only + * be called during application startup; it is not thread safe. + * + * @param listener + */ + final public void addComponentOnAfterRenderListener(IComponentOnAfterRenderListener listener) + { + if (componentOnAfterRenderListeners == null) + { + componentOnAfterRenderListeners = new ArrayList(); + } + + if (componentOnAfterRenderListeners.contains(listener) == false) + { + componentOnAfterRenderListeners.add(listener); + } + } + + /** + * Removes an [EMAIL PROTECTED] IComponentOnAfterRenderListener}. + * + * @param listener + */ + final public void removeComponentOnAfterRenderListener(IComponentOnAfterRenderListener listener) + { + if (componentOnAfterRenderListeners != null) + { + componentOnAfterRenderListeners.remove(listener); + if (componentOnAfterRenderListeners.isEmpty()) + { + componentOnAfterRenderListeners = null; + } + } + } + + /** + * Notifies the [EMAIL PROTECTED] IComponentOnAfterRenderListener}s. + * + * @param component + */ + final void notifyComponentOnAfterRenderListeners(Component component) + { + if (componentOnAfterRenderListeners != null) + { + for (Iterator i = componentOnAfterRenderListeners.iterator(); i.hasNext();) + { + IComponentOnAfterRenderListener listener = (IComponentOnAfterRenderListener) i.next(); + listener.onAfterRender(component); + } } } } 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=544789&r1=544788&r2=544789 ============================================================================== --- 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 Wed Jun 6 03:00:29 2007 @@ -3048,6 +3048,7 @@ { setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false); onBeforeRender(); + getApplication().notifyComponentOnBeforeRenderListeners(this); if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED)) { throw new IllegalStateException( @@ -3093,6 +3094,7 @@ { setFlag(FLAG_AFTER_RENDERING, true); onAfterRender(); + getApplication().notifyComponentOnAfterRenderListeners(this); if (getFlag(FLAG_AFTER_RENDERING)) { throw new IllegalStateException( Added: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnAfterRenderListener.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnAfterRenderListener.java?view=auto&rev=544789 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnAfterRenderListener.java (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnAfterRenderListener.java Wed Jun 6 03:00:29 2007 @@ -0,0 +1,32 @@ +/* + * 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.application; + +import org.apache.wicket.Component; + +/** + * Listener that is called after component's onAfterRender method was invoked. + * + * @author Matej Knopp + */ +public interface IComponentOnAfterRenderListener +{ + /** + * @param component + */ + public void onAfterRender(Component component); +} Added: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnBeforeRenderListener.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnBeforeRenderListener.java?view=auto&rev=544789 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnBeforeRenderListener.java (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IComponentOnBeforeRenderListener.java Wed Jun 6 03:00:29 2007 @@ -0,0 +1,33 @@ +/* + * 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.application; + +import org.apache.wicket.Component; + +/** + * Listener that is called right after the component's onBeforeRender method was + * invoked. + * + * @author Matej Knopp + */ +public interface IComponentOnBeforeRenderListener +{ + /** + * @param component + */ + public void onBeforeRender(Component component); +}