You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/12/04 23:40:55 UTC

git commit: TAP5-2249: Empty If with CSS class causes a RenderQueueException

Updated Branches:
  refs/heads/master fc72c4dc6 -> 1334bb926


TAP5-2249: Empty If with CSS class causes a RenderQueueException


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/1334bb92
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/1334bb92
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/1334bb92

Branch: refs/heads/master
Commit: 1334bb9261f0a35dc1505745c74baf5aeda43adb
Parents: fc72c4d
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Dec 4 14:29:07 2013 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Dec 4 14:29:07 2013 -0800

----------------------------------------------------------------------
 .../corelib/base/AbstractConditional.java       | 16 +++++++++-----
 tapestry-core/src/test/app1/EmptyIfDemo.tml     | 20 ++++++++++++++++++
 .../integration/app1/BlockTests.groovy          | 13 ++++++++++++
 .../integration/app1/pages/EmptyIfDemo.groovy   | 22 ++++++++++++++++++++
 .../tapestry5/integration/app1/pages/Index.java |  2 ++
 .../resources/META-INF/assets/empty-if-demo.css |  9 ++++++++
 6 files changed, 77 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractConditional.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractConditional.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractConditional.java
index 615b6ce..f059d12 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractConditional.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractConditional.java
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009-2013 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -26,6 +26,8 @@ import org.apache.tapestry5.ioc.annotations.Inject;
  * Base class for {@link org.apache.tapestry5.corelib.components.If} and {@link org.apache.tapestry5.corelib.components.Unless}.
  * Will render its body or the block from its else parameter.  If it renders anything and it has an element name, then
  * it renders the element and its informal parameters.
+ *
+ * @tapestrydoc
  */
 @SupportsInformalParameters
 public abstract class AbstractConditional
@@ -56,11 +58,13 @@ public abstract class AbstractConditional
      */
     Object beginRender(MarkupWriter writer)
     {
-        Block toRender = test() ? resources.getBody() : elseBlock;
+        boolean enabled = test();
+
+        Block toRender = enabled ? resources.getBody() : elseBlock;
 
         String elementName = resources.getElementName();
 
-        renderTag = toRender != null && elementName != null;
+        renderTag = enabled && elementName != null;
 
         if (renderTag)
         {
@@ -73,17 +77,19 @@ public abstract class AbstractConditional
 
     /**
      * If {@link #test()} is true, then the body is rendered, otherwise not. The component does not have a template or
-     * do any other rendering besides its body.
+     * do any other rendering besides its body (and possibly an element around its body).
      */
     boolean beforeRenderBody()
     {
         return false;
     }
 
-    void afterRenderBody(MarkupWriter writer)
+    void afterRender(MarkupWriter writer)
     {
         if (renderTag)
+        {
             writer.end();
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/test/app1/EmptyIfDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/EmptyIfDemo.tml b/tapestry-core/src/test/app1/EmptyIfDemo.tml
new file mode 100644
index 0000000..eb7ea8e
--- /dev/null
+++ b/tapestry-core/src/test/app1/EmptyIfDemo.tml
@@ -0,0 +1,20 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
+
+    <h1>Empty If Demo</h1>
+
+    <style>
+    </style>
+
+
+    <div t:type="if" test="show" class="header-seperator"/>
+
+    <div class="btn-toolbar">
+        <div class="btn-group">
+            <t:actionlink t:id="show" class="btn btn-default">Show</t:actionlink>
+            <t:actionlink t:id="hide" class="btn btn-default">Hide</t:actionlink>
+        </div>
+
+    </div>
+
+</html>
+

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/BlockTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/BlockTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/BlockTests.groovy
index d9a3004..0673c2e 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/BlockTests.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/BlockTests.groovy
@@ -29,4 +29,17 @@ class BlockTests extends App1TestCase
 
         assertText "testtitle", "Component Inside Block"
     }
+
+    // Test for TAP5-2249
+    @Test
+    void empty_if_will_render_a_tag() {
+
+        openLinks "Empty If Demo", "Hide"
+
+        assertEquals 0, getCssCount(".header-seperator")
+
+        clickAndWait "link=Show"
+
+        assertEquals 1, getCssCount(".header-seperator")
+    }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/EmptyIfDemo.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/EmptyIfDemo.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/EmptyIfDemo.groovy
new file mode 100644
index 0000000..7db3399
--- /dev/null
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/pages/EmptyIfDemo.groovy
@@ -0,0 +1,22 @@
+package org.apache.tapestry5.integration.app1.pages
+
+import org.apache.tapestry5.annotations.Import
+import org.apache.tapestry5.annotations.Persist
+
+// See TAP5-2249
+@Import(stylesheet = "empty-if-demo.css")
+class EmptyIfDemo {
+
+    @Persist
+    boolean show
+
+    void onActionFromHide() {
+        show = false
+    }
+
+    void onActionFromShow() {
+        show = true
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index efd1345..c74afd9 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -59,6 +59,8 @@ public class Index
     private static final List<Item> ITEMS = CollectionFactory
             .newList(
 
+                    new Item("EmptyIfDemo", "Empty If Demo", "Ensure an empty If can still render."),
+
                     new Item("MissingAssetDemo", "Missing Asset Demo", "Error when injecting an asset that does not exist."),
 
                     new Item("ConfirmDemo", "Confirm Mixin Demo", "Confirm an action when clicking it."),

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1334bb92/tapestry-core/src/test/resources/META-INF/assets/empty-if-demo.css
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/resources/META-INF/assets/empty-if-demo.css b/tapestry-core/src/test/resources/META-INF/assets/empty-if-demo.css
new file mode 100644
index 0000000..a30dda7
--- /dev/null
+++ b/tapestry-core/src/test/resources/META-INF/assets/empty-if-demo.css
@@ -0,0 +1,9 @@
+.header-seperator {
+    width: 100%;
+    height: 70px;
+    color: silver;
+}
+
+.header-seperator::after {
+    content: "Tag did render.";
+}