Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x 6eef0a12c -> 961d6cde4


WICKET-6231 wicket:enclosure and getVariation().

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

Branch: refs/heads/wicket-7.x
Commit: 961d6cde4fe6f434a44385a6dc5f5b187816f169
Parents: 6eef0a1
Author: Andrea Del Bene <[email protected]>
Authored: Mon Aug 29 12:00:34 2016 +0200
Committer: Andrea Del Bene <[email protected]>
Committed: Mon Aug 29 12:01:00 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/Component.java  |  3 ++
 .../wicket/markup/MarkupVariationTest.java      | 32 ++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/961d6cde/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 2f6715e..a309732 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -980,6 +980,9 @@ public abstract class Component
         */
        public final void beforeRender()
        {
+               //clear any possible markup loaded before rendering phase
+               setMarkup(null);
+               
                if (this instanceof IFeedback)
                {
                        // this component is a feedback. Feedback must be 
initialized last, so that

http://git-wip-us.apache.org/repos/asf/wicket/blob/961d6cde/wicket-core/src/test/java/org/apache/wicket/markup/MarkupVariationTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/MarkupVariationTest.java 
b/wicket-core/src/test/java/org/apache/wicket/markup/MarkupVariationTest.java
index 65cc4d2..705e075 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/markup/MarkupVariationTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/MarkupVariationTest.java
@@ -25,6 +25,7 @@ import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.StringResourceStream;
+import org.apache.wicket.util.tester.FormTester;
 import org.apache.wicket.util.tester.WicketTestCase;
 import org.junit.Test;
 
@@ -61,6 +62,20 @@ public class MarkupVariationTest extends WicketTestCase
        {
                return (MarkupContainer) 
tester.getComponentFromLastRenderedPage("p");
        }
+       
+       /**
+        * https://issues.apache.org/jira/browse/WICKET-6231
+        */
+       @Test
+       public void changeVariationBeforeRendering() throws Exception
+       {
+               tester.startPage(new VariationPage());
+               FormTester formTester = tester.newFormTester("p:a_form");
+               
+               formTester.submit();
+               
+               tester.assertContainsNot("One");
+       }
 
        private static class VariationPage extends WebPage implements 
IMarkupResourceStreamProvider
        {
@@ -95,14 +110,22 @@ public class MarkupVariationTest extends WicketTestCase
                                @Override
                                public void onClick(AjaxRequestTarget target)
                                {
-                                       variation = "one".equals(variation) ? 
"two" : "one";
+                                       changeVariation();
                                        target.add(VariationPanel.this);
                                }
                        });
 
                        add(new Label("simpleLabel", "Label"));
 
-                       add(new Form<Void>("a_form"));
+                       add(new Form<Void>("a_form")
+                       {
+                               @Override
+                               protected void onSubmit()
+                               {
+                                       super.onSubmit();
+                                       changeVariation();
+                               }
+                       });
 
                        add(new Label("child", "Inline Enclosure child text"));
                        add(new Label("nestedChild", "Nested Inline Enclosure 
child text"));
@@ -114,5 +137,10 @@ public class MarkupVariationTest extends WicketTestCase
                {
                        return variation;
                }
+
+               private void changeVariation()
+               {
+                       variation = "one".equals(variation) ? "two" : "one";
+               }
        }
 }

Reply via email to