Revision: 406
          http://svn.sourceforge.net/stripes/?rev=406&view=rev
Author:   tfenne
Date:     2006-09-03 06:16:58 -0700 (Sun, 03 Sep 2006)

Log Message:
-----------
Fix for STS-264: JavaScriptBuilder cannot deal with hibernate proxies.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java

Modified: trunk/stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java       
2006-09-02 17:38:44 UTC (rev 405)
+++ trunk/stripes/src/net/sourceforge/stripes/ajax/JavaScriptBuilder.java       
2006-09-03 13:16:58 UTC (rev 406)
@@ -28,6 +28,7 @@
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
+import java.lang.reflect.Method;
 
 /**
  * <p>Builds a set of JavaScript statements that will re-construct the value 
of a Java object,
@@ -160,13 +161,17 @@
 
     /**
      * Returns true if the supplied type should be excluded from conversion, 
otherwise
-     * returns false.
+     * returns false.  A class should be excluded if it is assignable to one 
of the types
+     * listed for exclusion, or, it is an array of such a type.
      */
     public boolean isExcludedType(Class<?> type) {
         for (Class<?> excludedType : this.excludeClasses) {
             if (excludedType.isAssignableFrom(type)) {
                 return true;
             }
+            else if (type.isArray() && 
excludedType.isAssignableFrom(type.getComponentType())) {
+                return true;
+            }
         }
 
         return false;
@@ -329,23 +334,26 @@
 
         for (PropertyDescriptor property : props) {
             try {
-                Object value = property.getReadMethod().invoke(in);
+                Method readMethod = property.getReadMethod();
+                if (readMethod != null) {
+                    Object value = property.getReadMethod().invoke(in);
 
-                if (isExcludedType(property.getPropertyType()) || value == 
null) {
-                    continue;
-                }
+                    if (isExcludedType(property.getPropertyType()) || value == 
null) {
+                        continue;
+                    }
 
-                if (isScalarType(value)) {
-                    if (out.length() > 1) {
-                        out.append(", ");
+                    if (isScalarType(value)) {
+                        if (out.length() > 1) {
+                            out.append(", ");
+                        }
+                        out.append(property.getName());
+                        out.append(":");
+                        out.append( getScalarAsString(value) );
                     }
-                    out.append(property.getName());
-                    out.append(":");
-                    out.append( getScalarAsString(value) );
+                    else {
+                        buildNode(targetName + "." + property.getName(), 
value);
+                    }
                 }
-                else {
-                    buildNode(targetName + "." + property.getName(), value);
-                }
             }
             catch (Exception e) {
                 log.warn(e, "Could not translate property [", 
property.getName(), "] of type [",


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to