cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: PropertyUtils.getProperty handling of nulls in intermediate / nested paths
Date Wed, 09 Oct 2013 19:41:03 GMT
The ?. in Tapestry works for me (we use it a bit).  Best of both worlds
then.

mrg



On Wed, Oct 9, 2013 at 3:02 PM, Andrus Adamchik <andrus@objectstyle.org>wrote:

> I am totally familiar with the issue. BTW here is the current Tapestry
> approach to optional relationships (which IIRC evolved after trying
> different things over the years) [1] :
>
> user.name  // NPE is thrown
> user?.name // Null is returned
>
> Andrus
>
> [1] http://tapestry.apache.org/property-expressions.html
>
>
>
> On Oct 9, 2013, at 2:29 PM, John Huss <johnthuss@gmail.com> wrote:
>
> > Currently if you call PropertyUtils.getProperty with a chain of
> properties,
> > like "painting.name" and a part of the chain is null you get
> > UnresolvablePathException("Null value in the middle of the path…").  I
> > believe it was done this way to match
> > org.apache.commons.beanutils.BeanUtils.getNestedProperty
> >
> > To me this is undesirable - I'd rather have it just return null and stop
> > evaluation.  That's how key value coding works in WebObjects.  I just
> have
> > trouble seeing where an exception would be preferable to returning null.
> > I'd be interested in either changing the behavior or adding an optional
> > boolean flag that controls whether an exception is thrown or not.  On the
> > other hand, it's simple enough to create my own static method that wraps
> > this call and catches the exception.
> >
> > Does anyone else have an opinion on this?
> >
> > John
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message