You're welcome Dmitriy.  One thing I should have said was that my example
${...} forced coercion to a String, which may / may not be required in your
case.

Regards,
Jim.

-----Original Message-----
From: Dmitriy Vsekhvalnov [mailto:dvsekhval...@gmail.com] 
Sent: 14 October 2010 11:27
To: Tapestry users
Subject: Re: Component to format null values

you opened my eyes. Thanks.

On Thu, Oct 14, 2010 at 12:21 PM, Jim O'Callaghan
<jc1000...@yahoo.co.uk>wrote:

> I think you can use the format:
>
> <t:formatnull value="${contract?.manager?.address?.city?.name}" />
>
> ... where if any of the hierarchy is null is will stop trying to evaluate
> methods / properties on subordinates, avoiding your NPE.
>
> Regards,
> Jim.
>
> -----Original Message-----
> From: Dmitriy Vsekhvalnov [mailto:dvsekhval...@gmail.com]
> Sent: 14 October 2010 09:01
> To: users@tapestry.apache.org
> Subject: Component to format null values
>
> Hello all,
>
> i'm looking to some approach to render property value or some default
> string
> if value is null.
>
> Something like:
>   <t:formatnull value="contract.name" />
>
> I have no problem to implement such component,but i want this to work with
> property chains as well:
>
>  <t:formatnull value="contract.manager.address.city.name" />
>
> where i want default string to be rendered, if any of intermediate values
> evaluated to null. Now i'm getting NPE.
>
> Is there are any service in tapestry which i can use for property
> expressions evaluation or any other ideas?
>
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to