tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drew Davidson <d...@ognl.org>
Subject Re: OGNL
Date Wed, 06 Aug 2003 20:30:09 GMT
Richard Lewis-Shell wrote:

>>Say, one aspect of Struts I find very annoying is that when I'm using
>>their expressions to access JBs and a null is down the line (ie.
>>"office.city.address.line1" and address is null).  I want to handle
>>this as elegantly as possible in Tapestry without adding a null handler
>>to every JB class.  Can I add the null handler to an abstract class and
>>have it effect instances of inherited classes?  This seems to be an
>>OGNL question.
>i'd love to be able to do this across inheritance hierarchies too. i.e. a
>default null handler that would apply if no other handler were specified
>would be excellent.  effectively just wanting a way to have OGNL evaluate an
>expression "a.b.c.d" as null if _any_ of "a", "a.b", "a.b.c", or "a.b.c.d"
>evaluate to null.
You could set the NullHandler for Object.class and that would get called 
when any object has a null evaluation:

        OgnlRuntime.setNullHandler( Object.class,  new 

The default NullHander (ObjectNullHandler) gets installed this way and 
simply allows null to filter through and cause NullPointerExceptions.  
You could install one that interrogates the target object  for its class 
and proceeds from there.

- Drew

< Drew Davidson | OGNL Technology >
<     Professional Open Source    >
|  Email: drew@ognl.org          /
|    Web: http://www.ognl.org   /
|    Vox: (520) 531-1966       <
|    Fax: (520) 531-1965        \
| Mobile: (520) 405-2967         \

View raw message