Revision: 396
Author:   tfenne
Date:     2006-08-28 18:36:09 -0700 (Mon, 28 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/stripes/?rev=396&view=rev

Log Message:
-----------
Fix for STS-253: make use of inner class enums easier by automatically trying 
foo.bar.Splat$SplatType if Class.forName() fails when foo.bar.Splat.SplatType 
is specified.

Modified Paths:
--------------
    
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
Modified: 
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java   
    2006-08-29 00:54:40 UTC (rev 395)
+++ 
trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionsEnumerationTag.java   
    2006-08-29 01:36:09 UTC (rev 396)
@@ -84,10 +84,22 @@
             clazz = (Class<Enum>) ReflectUtil.findClass(this.className);
         }
         catch (Exception e) {
-            throw new StripesJspException
-                    ("Could not process class [" + this.className + "]. 
Attribute 'enum' on " +
-                            "tag options-enumeration must be the fully 
qualified name of a " +
-                            "class which is a java 1.5 enum.", e);
+            // Try replacing the last period with a $ just in case the enum in 
question
+            // is an inner class of another class
+            try {
+                int last = this.className.lastIndexOf('.');
+                if (last > 0) {
+                    String n2 = new StringBuilder(className).replace(last, 
last+1, "$").toString();
+                    clazz = ReflectUtil.findClass(n2);
+                }
+            }
+            // If our second attempt didn't work, wrap the *original* exception
+            catch (Exception e2) {
+                throw new StripesJspException
+                        ("Could not process class [" + this.className + "]. 
Attribute 'enum' on " +
+                         "tag options-enumeration must be the fully qualified 
name of a " +
+                         "class which is a java 1.5 enum.", e);
+            }
         }
 
         if (!clazz.isEnum()) {


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