WICKET-4377
Deprecate Component#onMarkupAttached()

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0a6706ab
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0a6706ab
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0a6706ab

Branch: refs/heads/sandbox/feedback
Commit: 0a6706ab2baf158272254a9fa54278c3912a91c4
Parents: 2f57d70
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Wed Feb 1 10:53:49 2012 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Wed Feb 1 10:53:49 2012 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/Component.java |   37 ------
 .../java/org/apache/wicket/MarkupContainer.java    |   13 +--
 .../org/apache/wicket/OnMarkupAttachedTest.java    |   97 ---------------
 3 files changed, 1 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0a6706ab/wicket-core/src/main/java/org/apache/wicket/Component.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java 
b/wicket-core/src/main/java/org/apache/wicket/Component.java
index e80013c..2552fea 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -733,34 +733,6 @@ public abstract class Component
        }
 
        /**
-        * Called when the component gets added to a parent
-        * 
-        * @return false, if it was called the first time
-        */
-       private boolean internalOnMarkupAttached()
-       {
-               boolean rtn = getFlag(FLAG_MARKUP_ATTACHED);
-               if (rtn == false)
-               {
-                       setFlag(FLAG_MARKUP_ATTACHED, true);
-                       onMarkupAttached();
-               }
-               return rtn;
-       }
-
-       /**
-        * Can be subclassed by any user to implement init-like logic which 
requires the markup to be
-        * available
-        */
-       protected void onMarkupAttached()
-       {
-               if (log.isDebugEnabled())
-               {
-                       log.debug("Markup available {}", toString());
-               }
-       }
-
-       /**
         * @return The 'id' attribute from the associated markup tag
         */
        public final String getMarkupIdFromMarkup()
@@ -880,15 +852,6 @@ public abstract class Component
        protected void onInitialize()
        {
                setRequestFlag(RFLAG_INITIALIZE_SUPER_CALL_VERIFIED, true);
-
-               try
-               {
-                       internalOnMarkupAttached();
-               }
-               catch (WicketRuntimeException exception)
-               {
-                       // ignore
-               }
        }
 
        /**

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a6706ab/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java 
b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 0c13dbe..cf6cfbd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1901,20 +1901,9 @@ public abstract class MarkupContainer extends Component 
implements Iterable<Comp
        }
 
        /**
-        * @see org.apache.wicket.Component#onMarkupAttached()
-        */
-       @Override
-       protected void onMarkupAttached()
-       {
-               super.onMarkupAttached();
-
-               // createAndAddComponentsForWicketTags();
-       }
-
-
-       /**
         * Automatically create components for <wicket:xxx> tag.
         */
+       // to use it call it from #onInitialize()
        private void createAndAddComponentsForWicketTags()
        {
                // Markup must be available

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a6706ab/wicket-core/src/test/java/org/apache/wicket/OnMarkupAttachedTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/OnMarkupAttachedTest.java 
b/wicket-core/src/test/java/org/apache/wicket/OnMarkupAttachedTest.java
deleted file mode 100644
index c0fb65a..0000000
--- a/wicket-core/src/test/java/org/apache/wicket/OnMarkupAttachedTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.wicket.markup.IMarkupResourceStreamProvider;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.util.resource.IResourceStream;
-import org.apache.wicket.util.resource.StringResourceStream;
-import org.junit.Test;
-
-/**
- * Verifies that each Component's onMarkupAttached() is called exactly once
- * for its lifecycle.
- *
- * https://issues.apache.org/jira/browse/WICKET-4361
- *
- * @since 1.5.5
- */
-public class OnMarkupAttachedTest extends WicketTestCase
-{
-       @Test
-       public void onMarkupAttached()
-       {
-               AtomicInteger counter = new AtomicInteger(0);
-               OnMarkupAttachedPage page = new OnMarkupAttachedPage(counter);
-               tester.startPage(page);
-
-               assertEquals(3, counter.get());
-       }
-       
-       private static class OnMarkupAttachedPage extends WebPage implements 
IMarkupResourceStreamProvider
-       {
-               private final AtomicInteger counter;
-
-               private OnMarkupAttachedPage(AtomicInteger counter)
-               {
-                       this.counter = counter;
-
-                       WebMarkupContainer comp1 = new WebMarkupContainer("one")
-                       {
-                               @Override
-                               protected void onMarkupAttached()
-                               {
-                                       super.onMarkupAttached();
-                                       assertEquals(1, 
getCounter().getAndIncrement());
-                               }
-                       };
-                       
-                       WebMarkupContainer comp2 = new WebMarkupContainer("two")
-                       {
-                               @Override
-                               protected void onMarkupAttached()
-                               {
-                                       super.onMarkupAttached();
-                                       assertEquals(2, 
getCounter().getAndIncrement());
-                               }
-                       };
-                       comp1.add(comp2);
-                       add(comp1);
-               }
-
-               @Override
-               protected void onMarkupAttached()
-               {
-                       super.onMarkupAttached();
-                       assertEquals(0, counter.getAndIncrement());
-               }
-
-               private AtomicInteger getCounter()
-               {
-                       return counter;
-               }
-
-               @Override
-               public IResourceStream getMarkupResourceStream(MarkupContainer 
container, Class<?> containerClass)
-               {
-                       return new StringResourceStream("<html><body><div 
wicket:id='one'><div wicket:id='two'></div></div></body></html>");
-               }
-       }
-}

Reply via email to