Author: gvanmatre
Date: Sat Feb 11 08:40:15 2006
New Revision: 377001

URL: http://svn.apache.org/viewcvs?rev=377001&view=rev
Log:
Added more exception handling to the clayForEach callback.

Modified:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/Bundle.properties
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/Bundle.properties
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/Bundle.properties?rev=377001&r1=377000&r2=377001&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/Bundle.properties 
(original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/Bundle.properties 
Sat Feb 11 08:40:15 2006
@@ -142,6 +142,7 @@
 missing.attribute=The "{0}" attribute is required when using the 
ClayAmalgam.{1}() validator method binding event.
 invalid.binding=Invalid use of the ClayAmalgam.{0}() validator method binding 
event.  This method assume the use of the Clay component's "shapeValidator" 
property binding.
 invalid.attribute=The "{0}" attribute is required when using the 
ClayAmalgam.{1}() validator method binding event.
+invalid.collectiontype=Evaluation of the value expression "{0}" did not return 
a valid collection type.  The clayForEach only allows List, Map and Object[] 
types.
 
 #(ALL)
 clay.null.tagUtils=The utility managed bean 
"org.apache.shale.TAG_UTILITY_BEAN" registered in the core shale jar cannot be 
resolved.   

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java?rev=377001&r1=377000&r2=377001&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 Sat Feb 11 08:40:15 2006
@@ -170,7 +170,7 @@
         String value = (String) clay.getAttributes().get("value");
         value = tagUtils.eval(value);
         if (value == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayOut"}));    
+            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayOut"}));    
         }
         
         boolean escapeXml = false;
@@ -234,7 +234,7 @@
         Clay clay = (Clay) component;
         String url = (String) clay.getAttributes().get("url");
         if (url == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] {"url", 
"clayImport"}));    
+            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"url", "clayImport"}));    
         }
         url = tagUtils.eval(url);
         
@@ -331,25 +331,19 @@
         Clay clay = (Clay) component;
         String value = (String) clay.getAttributes().get("value");
         if (value == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayForEach"}));    
+            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayForEach"}));    
         }
 
         String bodyJsfid = (String) clay.getAttributes().get("bodyJsfid");
         bodyJsfid = tagUtils.eval(bodyJsfid);
         if (bodyJsfid == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] 
{"bodyJsfid", "clayForEach"}));    
+            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"bodyJsfid", "clayForEach"}));    
         }
 
         String var = (String) clay.getAttributes().get("var");
         var = tagUtils.eval(var);
         if (var == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] {"var", 
"clayForEach"}));    
-        }
- 
-        String scope = (String) clay.getAttributes().get("scope");
-        scope = tagUtils.eval(scope);
-        if ((scope == null) || !(scope.equals("session") || 
scope.equals("request"))) {
-           scope = "session";    
+            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"var", "clayForEach"}));    
         }
             
         // lookup the ConfigBean that handles the bodyJsfid
@@ -362,7 +356,7 @@
         if (b == null)
             throw new NullPointerException(messages.getMessage(
                     "clay.jsfid.notfound", new Object[] { bodyJsfid }));
-
+  
         ValueBinding vb = context.getApplication().createValueBinding(value);
         final Object valueList = vb.getValue(context);
                 
@@ -395,7 +389,10 @@
                     };
 
                 };
-            }
+           } else {
+              throw new IllegalArgumentException(
+                      messages.getMessage("invalid.collectiontype", new 
Object[] {value}));
+           }
         }
        
         if (vi != null) {



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

Reply via email to