You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Danner, Russ" <Da...@csps.com> on 2005/10/14 23:52:25 UTC

Question about property resolution

Hello all,

 

First before ranting... I want to say THANK YOU for this framework
implementation.  I think it is great. 

                                    

And now the rant :-)

The My Faces property resolver uses an algorithm for getType that first
checks to see if the resolved "Base" object is a map.

When the object is a map the code looks inside the map then responds with
the outcome.

 

This works great when the bean I have is ONLY a map.  Suppose I have a class
which implements map, but also has other bean properties that need to be
addressed.  

 

There needs to be some precedence: like BEAN interface then SPECIAL
interfaces or visa versa. But we cannot simply treat maps as if they are not
beans.  We should not create an environment in which beans can be either a
first or second class citizen. 

 

I think the bean standard should be respected first then any other special
interface resolver should be able to be plugged in. 

IE one for maps, another for dynamic beans etc.

 

 

We should correct this as it creates incompatibility with applications
implemented with the java RI.

 

See attached code:

    public Class getType(Object base, Object property)

    {

        try

        {

            if (base == null || property == null ||

                property instanceof String && ((String)property).length() ==
0)

            {

                throw new PropertyNotFoundException("Bean is null");

            }

 

            if (base instanceof Map)

            {

                Object value = ((Map) base).get(property);

 

                // REVISIT: when generics are imlemented in JVM 1.5

                return (value == null) ? Object.class : value.getClass();

            }

 

            // If none of the special bean types, then process as normal
Bean

            PropertyDescriptor propertyDescriptor =

                getPropertyDescriptor(base, property.toString());

 

            return propertyDescriptor.getPropertyType();

        }

        catch (PropertyNotFoundException e) {

            throw e;

        }

        catch (Exception e)

        {

            return null;

        }

    }

 

Best Regards,

-R

______________________________________
R U S S   D A N N E R
Architect
Technology Services Group
[v] 617.450.3086 [f] 877.408.8154
[e] dannerr@csps.com
<bl...@csps.com> 

The First Church of Christ, Scientist
One Norway Street | Mailstop: C01-20
Boston, MA 02115-3195