[ 
http://www.stripesframework.org/jira/browse/STS-51?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ben Gunter closed STS-51.
-------------------------


> Binding confused by maps
> ------------------------
>
>                 Key: STS-51
>                 URL: http://www.stripesframework.org/jira/browse/STS-51
>             Project: Stripes
>          Issue Type: Bug
>            Reporter: Greg Hinkle
>            Assignee: Tim Fennell
>             Fix For: Release 1.0
>
>
> With the new deep class type figurer outerer, a map type at least one level 
> deep in the hierarchy will fail to be able to determine the type or create 
> the object.
> Since there is no information to determine the map type (unless we want to 
> have a custom extension to the javabean spec as we have done before) we'll 
> just assume maps only contain strings.
> (FYI, my past support for intelligent map type setting was done by looking 
> for put-Property-(<String>,<T>) methods and assuming that T is our map type 
> and -property- is our map property name.)
> My latest OgnlUtil.getPropertyClass impl:
>     public static Class getPropertyClass(String property, Object root) throws 
> OgnlException,
>                                                                               
> IntrospectionException {
>         int propertyIndex = property.lastIndexOf(".");
>         int arrayIndex = property.lastIndexOf("[");
>         if (arrayIndex > 0) {
>             // Handle end maps, even with "." in their map entries
>             property = property.substring(0,arrayIndex);
>             propertyIndex = property.lastIndexOf(".");
>             return String.class; // Hack, if its a map, assume a string
>         }
>         Method method = null;
>         if (propertyIndex > 0) {
>             String parentProperty = property.substring(0,propertyIndex);
>             String childProperty = property.substring(propertyIndex+1);
>             // foo.bar.baz.splat => parent: "foo.bar.baz" and child: "id"
>             OgnlContext context = createContext();
>             
> context.put(OgnlCustomNullHandler.INSTANTIATE_LEAF_NODES,OgnlCustomNullHandler.INSTANTIATE_LEAF_NODES);
>             root = Ognl.getValue(getExpression(parentProperty + ".class"), 
> context, root);
>             property = childProperty;
>             method =
>                     OgnlRuntime.getGetMethod(createContext(), (Class) root, 
> property);
>         } else {
>              method =
>                     OgnlRuntime.getGetMethod(createContext(), 
> root.getClass(), property);
>         }
>         if (method == null)
>                 throw new IntrospectionException("The property [" + property 
> + "] could not be found on the type [" +
>                         root.getClass().getName() + "]");
>             return method.getReturnType();
>     }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to