You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/03/21 06:32:19 UTC

DO NOT REPLY [Bug 7309] New: - Mapped properties should work against a collection object as well as method definition only.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7309>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7309

Mapped properties should work against a collection object as well as method definition only.

           Summary: Mapped properties should work against a collection
                    object as well as method definition only.
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: arron@keyboardmonkey.com


Currently, mapped properties only work against...

public Object getMyMappedProperty(String key)

...and not...
public java.util.Map getMyMappedProperty()


The indexed properties work with both styles. Not following suit on mapped
properties limits the application. For example, as well as fetching individual
properties, the iterate tag in Struts can go over any collection, but it must
get the collection first. Currently not possible to return the collection and
use individual mapped properties at the same time.

Below is a patch to fix all this so it mirrors the ability of the current
indexed  properties.


cvs diff PropertyUtils.java
Index: PropertyUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/PropertyUtils.java,v
retrieving revision 1.22
diff -r1.22 PropertyUtils.java
584a585,597
>         } else {
>           /* means that the result has to be retrieved from a map */
>           Method readMethod = descriptor.getReadMethod();
>           if (readMethod != null) {
>             Object invokeResult = readMethod.invoke(bean, new Object[0]);
>             /* test and fetch from the map */
>             if (invokeResult instanceof java.util.Map) {
>               result = ((java.util.Map)invokeResult).get(key);
>             }
>           } else {
>             throw new NoSuchMethodException("Property '" + name +
>                     "' has no mapped getter method");
>           }
1391a1405,1417
>         } else {
>           /* means that the result has to be retrieved from a map */
>           Method readMethod = descriptor.getReadMethod();
>           if (readMethod != null) {
>             Object invokeResult = readMethod.invoke(bean, new Object[0]);
>             /* test and fetch from the map */
>             if (invokeResult instanceof java.util.Map) {
>               ((java.util.Map)invokeResult).put(key, value);
>             }
>           } else {
>             throw new NoSuchMethodException("Property '" + name +
>                     "' has no mapped getter method");
>           }

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>