Repository: wicket
Updated Branches:
  refs/heads/master 08f6a531a -> a6d73f46b


WICKET-6604 fixed bug where controllers of enclosures were not correctly 
repainted in ajax if they were outside enclosures


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

Branch: refs/heads/master
Commit: a6d73f46b30e0846701bc8fdf3039895520eea1d
Parents: 08f6a53
Author: Igor Vaynberg <[email protected]>
Authored: Fri Oct 26 12:11:41 2018 -0700
Committer: Igor Vaynberg <[email protected]>
Committed: Tue Oct 30 08:29:07 2018 -0700

----------------------------------------------------------------------
 .../protocol/http/AjaxEnclosureListener.java    | 13 +++-
 .../html/internal/AjaxEnclosurePage_4.html      | 11 +++
 .../html/internal/AjaxEnclosurePage_4.java      | 75 ++++++++++++++++++++
 .../markup/html/internal/AjaxEnclosureTest.java |  8 +++
 4 files changed, 105 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a6d73f46/wicket-core/src/main/java/org/apache/wicket/protocol/http/AjaxEnclosureListener.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AjaxEnclosureListener.java
 
b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AjaxEnclosureListener.java
index b966580..351d549 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AjaxEnclosureListener.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AjaxEnclosureListener.java
@@ -82,13 +82,22 @@ public class AjaxEnclosureListener implements 
AjaxRequestTarget.IListener
                                while (entriesItor.hasNext())
                                {
                                        Map.Entry<String, Component> entry = 
entriesItor.next();
-                                       String componentId = entry.getKey();
                                        Component component = entry.getValue();
                                        if (isControllerOfEnclosure(component, 
enclosure))
                                        {
+                                               final Component controller = 
component;
                                                target.add(enclosure);
                                                visit.dontGoDeeper();
-                                               keysToRemove.add(componentId);
+                                               enclosure.visitChildren(new 
IVisitor<Component, Void>() {
+                                                       @Override
+                                                       public void 
component(Component descendant, IVisit<Void> visit) {
+                                                               if (descendant 
== controller) {
+                                                                       // if 
the controlling component is in the enclosure we do not need to repaint it
+                                                                       // 
individually, it will be repainted as part of the enclosure repaint
+                                                                       
keysToRemove.add(controller.getId());
+                                                               }
+                                                       }
+                                               });
                                                break;
                                        }
                                }

http://git-wip-us.apache.org/repos/asf/wicket/blob/a6d73f46/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.html
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.html
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.html
new file mode 100644
index 0000000..8f54a85
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.html
@@ -0,0 +1,11 @@
+<html xmlns:wicket>
+<body>
+
+<form wicket:id="form">
+       <label wicket:enclosure="nameField">Name</label>
+       <input type="text" wicket:id="nameField"/>
+       <button wicket:id="submit">submit</button>
+</form>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/a6d73f46/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java
new file mode 100644
index 0000000..bdeb27d
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosurePage_4.java
@@ -0,0 +1,75 @@
+/*
+ * 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.markup.html.internal;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.PropertyModel;
+
+
+/**
+ * Mock page for testing.
+ * 
+ * @author Igor Vaynberg
+ * 
+ */
+public class AjaxEnclosurePage_4 extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       //final Label nameLabel;
+       final TextField<String> nameField;
+       final AjaxSubmitLink submit;
+       
+       private String name;
+       
+       /**
+        * Construct.
+        */
+       public AjaxEnclosurePage_4()
+       {
+
+               Form<?> form=new Form<Void>("form");
+               queue(form);
+               
+               //nameLabel=new Label("nameLabel", "Name");
+               //queue(nameLabel);
+               
+               nameField=new TextField<String>("nameField", new 
PropertyModel<String>(this, "name"));
+               nameField.setOutputMarkupId(true);
+               queue(nameField);
+
+               submit=new AjaxSubmitLink("submit") {
+                       @Override
+                       protected void onSubmit(AjaxRequestTarget target) {
+                               name="submitted";
+                               nameField.clearInput();
+                               target.add(nameField);
+                       }
+               };
+               queue(submit);
+               
+       }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/a6d73f46/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosureTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosureTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosureTest.java
index 5273c78..162e343 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosureTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/internal/AjaxEnclosureTest.java
@@ -271,6 +271,14 @@ class AjaxEnclosureTest extends WicketTestCase
                }
        }
 
+       @Test
+       public void controllingComponentOutsideEnclosureShouldBeRepainted() {
+               AjaxEnclosurePage_4 page = 
tester.startPage(AjaxEnclosurePage_4.class);
+               tester.clickLink(page.submit);
+               // assert the input tag is part of the ajax response
+               assert (tester.getLastResponseAsString().contains("<component 
id=\"" + page.nameField.getMarkupId() + "\""));
+       }
+
        private void ensureEnclosureIsVisible(Page ajaxPage, AtomicInteger n)
        {
                InlineEnclosure enclosure = 
findNthComponent(InlineEnclosure.class, ajaxPage, n);

Reply via email to