Author: hlship
Date: Thu Oct 16 09:45:38 2008
New Revision: 705279

URL: http://svn.apache.org/viewvc?rev=705279&view=rev
Log:
TAP5-284: A component parameter default method that returns a primtive(instead 
of an object instance) results in an runtime exception

Added:
    
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PrimitiveDefaultDemo.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/PrimitiveDefault.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PrimitiveDefaultDemo.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java?rev=705279&r1=705278&r2=705279&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
 Thu Oct 16 09:45:38 2008
@@ -210,7 +210,7 @@
         if (signatures.isEmpty()) return;
 
         builder.addln("if (! %s.isBound(\"%s\"))", resourcesFieldName, 
parameterName);
-        builder.addln("  %s(\"%s\", %s, %s());", BIND_METHOD_NAME, 
parameterName, resourcesFieldName, methodName);
+        builder.addln("  %s(\"%s\", %s, ($w) %s());", BIND_METHOD_NAME, 
parameterName, resourcesFieldName, methodName);
     }
 
     private void addWriterMethod(String fieldName, String cachedFieldName, 
boolean cache, String parameterName,

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PrimitiveDefaultDemo.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PrimitiveDefaultDemo.tml?rev=705279&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PrimitiveDefaultDemo.tml 
(added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PrimitiveDefaultDemo.tml 
Thu Oct 16 09:45:38 2008
@@ -0,0 +1,9 @@
+<html t:type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
+
+    <h1>Primitive Default Demo</h1>
+
+    <p>
+        Here it is:
+        <t:primitivedefault/>
+    </p>
+</html>

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=705279&r1=705278&r2=705279&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 Thu Oct 16 09:45:38 2008
@@ -2317,4 +2317,14 @@
 
         assertTextPresent("Failure inside pageAttached().");
     }
+
+    /**
+     * TAP5-284
+     */
+    public void default_method_for_parameter_returns_primitive()
+    {
+        start("Primitive Default Demo");
+
+        assertText("value", "99");
+    }
 }

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/PrimitiveDefault.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/PrimitiveDefault.java?rev=705279&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/PrimitiveDefault.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/PrimitiveDefault.java
 Thu Oct 16 09:45:38 2008
@@ -0,0 +1,37 @@
+//  Copyright 2008 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.tapestry5.integration.app1.components;
+
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.Parameter;
+
+public class PrimitiveDefault
+{
+    @Parameter
+    private int value;
+
+    int defaultValue() { return 99; }
+
+    boolean beginRender(MarkupWriter writer)
+    {
+        writer.element("div", "id", "value");
+
+        writer.write(String.valueOf(value));
+
+        writer.end();
+
+        return false;
+    }
+}

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PrimitiveDefaultDemo.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PrimitiveDefaultDemo.java?rev=705279&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PrimitiveDefaultDemo.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PrimitiveDefaultDemo.java
 Thu Oct 16 09:45:38 2008
@@ -0,0 +1,19 @@
+//  Copyright 2008 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.tapestry5.integration.app1.pages;
+
+public class PrimitiveDefaultDemo
+{
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java?rev=705279&r1=705278&r2=705279&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
 Thu Oct 16 09:45:38 2008
@@ -65,6 +65,9 @@
 
     private static final List<Item> ITEMS = CollectionFactory.newList(
 
+            new Item("PrimitiveDefaultDemo", "Primitive Default Demo",
+                     "Primitive value returned from parameter default method"),
+
             new Item("ValidateFormValidationExceptionDemo",
                      "ValidationForm ValidationException Demo",
                      "Throwing a ValidationException from the validateForm 
event handler."),
@@ -289,7 +292,8 @@
             new Item("InformalParametersDemo", "Informal Parameters Demo",
                      "Access to informal parameters names and values"),
 
-            new Item("FormFieldOutsideForm", "Form Field Outside Form", "Nice 
exception message for common problem of form fields outside forms")
+            new Item("FormFieldOutsideForm", "Form Field Outside Form",
+                     "Nice exception message for common problem of form fields 
outside forms")
     );
 
     static


Reply via email to