You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/03/12 18:14:06 UTC

svn commit: r517292 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/structure/ test/app1/WEB-INF/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/pages/

Author: hlship
Date: Mon Mar 12 10:14:05 2007
New Revision: 517292

URL: http://svn.apache.org/viewvc?view=rev&rev=517292
Log:
TAPESTRY-1344: Render phase methods should be allowed to return a Renderable object

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/RenderableDemo.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/RenderableDemo.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/Start.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?view=diff&rev=517292&r1=517291&r2=517292
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java Mon Mar 12 10:14:05 2007
@@ -31,6 +31,7 @@
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.Link;
 import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.Renderable;
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.internal.InternalComponentResources;
 import org.apache.tapestry.internal.TapestryInternalUtils;
@@ -141,6 +142,23 @@
                 add(command);
 
                 return false; // do not abort!
+            }
+
+            if (result instanceof Renderable)
+            {
+                final Renderable renderable = (Renderable) result;
+
+                RenderCommand wrapper = new RenderCommand()
+                {
+                    public void render(MarkupWriter writer, RenderQueue queue)
+                    {
+                        renderable.render(writer);
+                    }
+                };
+
+                add(wrapper);
+
+                return false;
             }
 
             throw new TapestryException(StructureMessages.wrongEventResultType(

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/RenderableDemo.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/RenderableDemo.html?view=auto&rev=517292
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/RenderableDemo.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/RenderableDemo.html Mon Mar 12 10:14:05 2007
@@ -0,0 +1,10 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+  
+  <h1>Renderable Demo</h1>
+  
+  <p>
+    The following text is provided by a Renderable: [<t:delegate to="renderable"/>]
+  </p>
+  
+  
+</html>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/Start.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/Start.html?view=diff&rev=517292&r1=517291&r2=517292
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/Start.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/Start.html Mon Mar 12 10:14:05 2007
@@ -57,15 +57,16 @@
             for component parameters </li>
           <li>
             <a t:type="PageLink" page="ValidForm">ValidForm</a> -- server-side input validation</li>
-        </ul>
-      </td>
-      <td>
-        <ul>
           <li>
             <a t:type="PageLink" page="AnyDemo">AnyDemo</a> -- test out the Any component </li>
           <li>
             <a t:type="PageLink" page="PasswordFieldDemo">PasswordFieldDemo</a> -- test for the
             PasswordField component </li>
+        </ul>
+      </td>
+      <td>
+        <ul>
+
           <li>
             <a t:type="PageLink" page="RenderComponentDemo">RenderComponentDemo</a> -- components
             that "nominate" other components to render </li>
@@ -118,6 +119,10 @@
           <li>
             <t:actionlink t:id="badreturntype">BadReturnType Demo</t:actionlink> -- Error report due
             to event handler method returning unacceptible return value (an Integer) </li>
+
+          <li>
+            <t:pagelink page="renderabledemo">Renderable Demo</t:pagelink> -- Shows that render
+            phase methods can return a Renderable object </li>
         </ul>
       </td>
     </tr>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=517292&r1=517291&r2=517292
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Mon Mar 12 10:14:05 2007
@@ -865,4 +865,13 @@
                 "An event handler for component org.apache.tapestry.integration.app1.pages.Start returned the value 20 (from method org.apache.tapestry.integration.app1.pages.Start.onActionFromBadReturnType() (at Start.java:34)). Return type java.lang.Integer can not be handled.");
 
     }
+
+    @Test
+    public void render_phase_method_may_return_renderable()
+    {
+        open(BASE_URL);
+        clickAndWait("link=Renderable Demo");
+
+        assertTextPresent("Renderable Demo", "[This proves it works.]");
+    }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/RenderableDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/RenderableDemo.java?view=auto&rev=517292
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/RenderableDemo.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/RenderableDemo.java Mon Mar 12 10:14:05 2007
@@ -0,0 +1,32 @@
+// Copyright 2007 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.
+// 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.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.Renderable;
+
+public class RenderableDemo
+{
+    public Renderable getRenderable()
+    {
+        return new Renderable()
+        {
+            public void render(MarkupWriter writer)
+            {
+                writer.write("This proves it works.");
+            }
+        };
+    }
+}



Re: svn commit: r517292 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/structure/ test/app1/WEB-INF/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/pages/

Posted by Jesse Kuhnert <jk...@gmail.com>.
Or recursive spirit? ;)

On 3/12/07, Massimo Lusetti <ml...@gmail.com> wrote:
> On 3/12/07, hlship@apache.org <hl...@apache.org> wrote:
> > Author: hlship
> > Date: Mon Mar 12 10:14:05 2007
> > New Revision: 517292
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=517292
> > Log:
> > TAPESTRY-1344: Render phase methods should be allowed to return a Renderable object
>
> Smells like ajax spirit... :)
>
> --
> Massimo
> http://meridio.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: svn commit: r517292 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/structure/ test/app1/WEB-INF/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/pages/

Posted by Massimo Lusetti <ml...@gmail.com>.
On 3/12/07, hlship@apache.org <hl...@apache.org> wrote:
> Author: hlship
> Date: Mon Mar 12 10:14:05 2007
> New Revision: 517292
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=517292
> Log:
> TAPESTRY-1344: Render phase methods should be allowed to return a Renderable object

Smells like ajax spirit... :)

-- 
Massimo
http://meridio.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org