Author: jholmes
Date: Wed Jun 15 12:29:43 2005
New Revision: 190794

URL: http://svn.apache.org/viewcvs?rev=190794&view=rev
Log:
Update TagUtils to provide a more specific error message in the case
where properties on a formbean are not found. Basically this change
handles the scenario where the Constants.BEAN_KEY value was being displayed
as the bean name. Now, the actualy bean name will be displayed.

Modified:
    
struts/taglib/trunk/src/java/org/apache/struts/taglib/LocalStrings.properties
    struts/taglib/trunk/src/java/org/apache/struts/taglib/TagUtils.java

Modified: 
struts/taglib/trunk/src/java/org/apache/struts/taglib/LocalStrings.properties
URL: 
http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/LocalStrings.properties?rev=190794&r1=190793&r2=190794&view=diff
==============================================================================
--- 
struts/taglib/trunk/src/java/org/apache/struts/taglib/LocalStrings.properties 
(original)
+++ 
struts/taglib/trunk/src/java/org/apache/struts/taglib/LocalStrings.properties 
Wed Jun 15 12:29:43 2005
@@ -6,7 +6,7 @@
 lookup.argument=Invalid argument looking up property {0} of bean {1}
 lookup.bean.any=Cannot find bean {0} in any scope
 lookup.bean=Cannot find bean {0} in scope {1}
-lookup.method=No getter method for property {0} of bean {1}
+lookup.method=No getter method for property: "{0}" of bean: "{1}"
 lookup.scope=Invalid bean scope {0}
 lookup.target=Exception thrown by getter for property {0} of bean {1}
 message.message=Missing message for key {0} in bundle {1} for locale {2}

Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/TagUtils.java
URL: 
http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/TagUtils.java?rev=190794&r1=190793&r2=190794&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/TagUtils.java 
(original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/TagUtils.java Wed Jun 
15 12:29:43 2005
@@ -976,8 +976,21 @@
 
         } catch (NoSuchMethodException e) {
             saveException(pageContext, e);
+            
+            String beanName = name;
+            
+            // Name defaults to Contants.BEAN_KEY if no name is specified by
+            // an input tag. Thus lookup the bean under the key and use
+            // its class name for the exception message.
+            if (Constants.BEAN_KEY.equals(name)) {
+               Object bean = pageContext.findAttribute(Constants.BEAN_KEY)
+               if (bean != null) {
+                       beanName = bean.getClass().getName();
+               }
+            }
+            
             throw new JspException(
-                    messages.getMessage("lookup.method", property, name));
+                    messages.getMessage("lookup.method", property, beanName));
         }
 
     }



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

Reply via email to