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 <[email protected]> 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
