Author: hlship
Date: Thu Sep 22 12:56:27 2005
New Revision: 291010

URL: http://svn.apache.org/viewcvs?rev=291010&view=rev
Log:
Improve exception reporting of certain objects, including object arrays

Added:
    
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/ObjectArrayRenderStrategy.java
    
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/PreformattedRenderStrategy.java
    
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/ObjectArrayRenderStrategyTest.java
    
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/PreformattedRenderableStrategyTest.java
Modified:
    
jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.jwc
    jakarta/tapestry/trunk/examples/Workbench/src/context/css/workbench.css
    
jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.describe.xml
    
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/PropertySelection.xml
    
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
    
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/BaseDescribeTestCase.java
    jakarta/tapestry/trunk/status.xml

Modified: 
jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.jwc
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.jwc?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- 
jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.jwc
 (original)
+++ 
jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/inspector/ShowProperties.jwc
 Thu Sep 22 12:56:27 2005
@@ -59,8 +59,10 @@
     <binding name="value" value="valueClassName"/>
   </component>
   
-  <component id="insertPersistValue" type="Describe">
-    <binding name="object" value="change.newValue"/>
-  </component>
+  <inject property="adapterFactory" 
object="service:tapestry.describe.RenderableAdapterFactory"/>
+    
+  <component id="insertPersistValue" type="Delegator">
+    <binding name="delegate" 
value="adapterFactory.getRenderableAdaptor(change.newValue)"/>
+  </component>  
   
 </component-specification>

Modified: 
jakarta/tapestry/trunk/examples/Workbench/src/context/css/workbench.css
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Workbench/src/context/css/workbench.css?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Workbench/src/context/css/workbench.css 
(original)
+++ jakarta/tapestry/trunk/examples/Workbench/src/context/css/workbench.css Thu 
Sep 22 12:56:27 2005
@@ -180,3 +180,9 @@
        margin-bottom: 0px;
        margin-left: 20px;
 }
+
+IMG
+{
+  border: none;
+}
+

Modified: 
jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.describe.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.describe.xml?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.describe.xml 
(original)
+++ 
jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.describe.xml 
Thu Sep 22 12:56:27 2005
@@ -79,7 +79,20 @@
        <contribution configuration-id="RenderStrategies">
                <strategy class="java.lang.Object" 
object="service:DefaultRenderStrategy"/>
                <strategy class="org.apache.hivemind.Location" 
object="instance:LocationRenderStrategy"/>
+               <strategy class="org.apache.hivemind.service.impl.ClassFabImpl" 
object="instance:PreformattedRenderStrategy"/>
+               <strategy class="java.lang.Object[]" 
object="service:ObjectArrayRenderStrategy"/>
        </contribution>
+       
+       <service-point id="ObjectArrayRenderStrategy" 
interface="RenderStrategy">
+               Renders an array of objects as an unordered list.
+       
+               <invoke-factory>
+                       <construct class="ObjectArrayRenderStrategy">
+                               <set-service property="renderStrategy" 
service-id="RenderStrategy"/>
+                       </construct>
+               </invoke-factory>       
+               
+       </service-point>
        
        <service-point id="RenderStrategy">
                

Modified: 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/PropertySelection.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/PropertySelection.xml?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/PropertySelection.xml
 (original)
+++ 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/PropertySelection.xml
 Thu Sep 22 12:56:27 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!--
+<!-- 
    Copyright 2004, 2005 The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");

Modified: 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
 (original)
+++ 
jakarta/tapestry/trunk/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
 Thu Sep 22 12:56:27 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!--
+<!-- 
    Copyright 2004, 2005 The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");

Added: 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/ObjectArrayRenderStrategy.java
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/ObjectArrayRenderStrategy.java?rev=291010&view=auto
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/ObjectArrayRenderStrategy.java
 (added)
+++ 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/ObjectArrayRenderStrategy.java
 Thu Sep 22 12:56:27 2005
@@ -0,0 +1,60 @@
+// Copyright 2005 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.describe;

+

+import org.apache.tapestry.IMarkupWriter;

+import org.apache.tapestry.IRequestCycle;

+

+/**

+ * Renders an object array as an unordered list; each element is recursively 
rendered.

+ * 

+ * @author Howard M. Lewis Ship

+ * @since 4.0

+ */

+public class ObjectArrayRenderStrategy implements RenderStrategy

+{

+    private RenderStrategy _renderStrategy;

+

+    public void renderObject(Object object, IMarkupWriter writer, 
IRequestCycle cycle)

+    {

+        Object[] array = (Object[]) object;

+

+        if (array.length == 0)

+        {

+            writer.begin("em");

+            writer.print("empty list");

+            writer.end();

+            return;

+        }

+

+        writer.begin("ul");

+

+        for (int i = 0; i < array.length; i++)

+        {

+            writer.begin("li");

+            _renderStrategy.renderObject(array[i], writer, cycle);

+            writer.end();

+

+        }

+

+        writer.end();

+    }

+

+    public void setRenderStrategy(RenderStrategy renderStrategy)

+    {

+        _renderStrategy = renderStrategy;

+    }

+

+}


Added: 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/PreformattedRenderStrategy.java
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/PreformattedRenderStrategy.java?rev=291010&view=auto
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/PreformattedRenderStrategy.java
 (added)
+++ 
jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/describe/PreformattedRenderStrategy.java
 Thu Sep 22 12:56:27 2005
@@ -0,0 +1,36 @@
+// Copyright 2005 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.describe;

+

+import org.apache.tapestry.IMarkupWriter;

+import org.apache.tapestry.IRequestCycle;

+

+/**

+ * Render stategy for objects whose toString() produces a good deal of text, 
where that text is

+ * easier to read if preformmatted (using the HTML &lt;pre&gt; element).

+ * 

+ * @author Howard M. Lewis Ship

+ * @since 4.0

+ */

+public class PreformattedRenderStrategy implements RenderStrategy

+{

+    public void renderObject(Object object, IMarkupWriter writer, 
IRequestCycle cycle)

+    {

+        writer.begin("pre");

+        writer.print(object.toString());

+        writer.end();

+    }

+

+}


Modified: 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/BaseDescribeTestCase.java
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/BaseDescribeTestCase.java?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/BaseDescribeTestCase.java
 (original)
+++ 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/BaseDescribeTestCase.java
 Thu Sep 22 12:56:27 2005
@@ -19,6 +19,10 @@
 import org.apache.tapestry.IRequestCycle;
 
 /**
+ * Base class for testing implementations of
+ * [EMAIL PROTECTED] org.apache.tapestry.describe.DescribableStrategy} and
+ * [EMAIL PROTECTED] org.apache.tapestry.describe.RenderStrategy}.
+ * 
  * @author Howard M. Lewis Ship
  * @since 4.0
  */

Added: 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/ObjectArrayRenderStrategyTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/ObjectArrayRenderStrategyTest.java?rev=291010&view=auto
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/ObjectArrayRenderStrategyTest.java
 (added)
+++ 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/ObjectArrayRenderStrategyTest.java
 Thu Sep 22 12:56:27 2005
@@ -0,0 +1,86 @@
+// Copyright 2005 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.describe;

+

+import org.apache.tapestry.IMarkupWriter;

+import org.apache.tapestry.IRequestCycle;

+

+/**

+ * Tests for [EMAIL PROTECTED] ObjectArrayRenderStrategy}.

+ * 

+ * @author Howard M. Lewis Ship

+ * @since 4.0

+ */

+public class ObjectArrayRenderStrategyTest extends BaseDescribeTestCase

+{

+    public void testEmpty()

+    {

+        Object[] array = new Object[0];

+

+        IMarkupWriter writer = newWriter();

+        IRequestCycle cycle = newCycle();

+

+        writer.begin("em");

+        writer.print("empty list");

+        writer.end();

+

+        replayControls();

+

+        new ObjectArrayRenderStrategy().renderObject(array, writer, cycle);

+

+        verifyControls();

+    }

+

+    public void testNonEmpty()

+    {

+        Object o1 = new Object();

+        Object o2 = new Object();

+

+        Object array = new Object[]

+        { o1, o2 };

+

+        IMarkupWriter writer = newWriter();

+        IRequestCycle cycle = newCycle();

+        RenderStrategy strategy = (RenderStrategy) 
newMock(RenderStrategy.class);

+

+        // Alas; this doesn't *prove* that the code executes

+        // in the right order, just that the messages for

+        // each mock execute in the right order. We'll

+        // trust that and the code and hope for the best.

+

+        writer.begin("ul");

+        writer.begin("li");

+

+        strategy.renderObject(o1, writer, cycle);

+

+        writer.end();

+        writer.begin("li");

+

+        strategy.renderObject(o2, writer, cycle);

+

+        writer.end();

+        writer.end();

+

+        replayControls();

+

+        ObjectArrayRenderStrategy subject = new ObjectArrayRenderStrategy();

+

+        subject.setRenderStrategy(strategy);

+

+        subject.renderObject(array, writer, cycle);

+

+        verifyControls();

+    }

+}


Added: 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/PreformattedRenderableStrategyTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/PreformattedRenderableStrategyTest.java?rev=291010&view=auto
==============================================================================
--- 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/PreformattedRenderableStrategyTest.java
 (added)
+++ 
jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/describe/PreformattedRenderableStrategyTest.java
 Thu Sep 22 12:56:27 2005
@@ -0,0 +1,44 @@
+// Copyright 2005 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.describe;

+

+import org.apache.tapestry.IMarkupWriter;

+import org.apache.tapestry.IRequestCycle;

+

+/**

+ * Tests for [EMAIL PROTECTED] PreformattedRenderStrategy}.

+ * 

+ * @author Howard M. Lewis Ship

+ */

+public class PreformattedRenderableStrategyTest extends BaseDescribeTestCase

+{

+    public void testRenderObject()

+    {

+        String object = "some verbose object";

+

+        IMarkupWriter writer = newWriter();

+        IRequestCycle cycle = newCycle();

+

+        writer.begin("pre");

+        writer.print(object);

+        writer.end();

+

+        replayControls();

+

+        new PreformattedRenderStrategy().renderObject(object, writer, cycle);

+

+        verifyControls();

+    }

+}


Modified: jakarta/tapestry/trunk/status.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/status.xml?rev=291010&r1=291009&r2=291010&view=diff
==============================================================================
--- jakarta/tapestry/trunk/status.xml (original)
+++ jakarta/tapestry/trunk/status.xml Thu Sep 22 12:56:27 2005
@@ -64,6 +64,7 @@
       <action type="fix" dev="DS" fixes-bug="TAPESTRY-476" due-to="Pierre-Yves 
Nicolas">Document PropertySelection component</action>
       <action type="fix" dev="DS" fixes-bug="TAPESTRY-485" due-to="Pierre-Yves 
Nicolas">Document Upload component</action>
       <action type="fix" dev="HLS" fixes-bug="TAPESTRY-660">Injecting meta 
data generates incorrect code for boolean properties</action>
+      <action type="update" dev="HLS">Improve exception reporting of certain 
objects, including object arrays</action>
     </release>
     <release version="4.0-beta-7" date="Sep 17 2005">
       <action type="fix" dev="HLS" fixes-bug="TAPESTRY-341">Need better 
line-precise reporting for listener method</action>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to