I think a more useful extension would be the Groovy :? operator

  expression ?: default-value

This could even be combined with the safe de-reference:

  foo?.bar?.baz ?: computeFooBarBaz()


BTW, existing syntax would do fine for you

<t:if test="! foo?.bar?.baz">
  <!-- Renders if foo, bar or baz is null or baz is falsey. -->
</t:if>



On Tue, Aug 23, 2011 at 4:41 AM, Denis Stepanov
<[email protected]> wrote:
>
>> How does it differ from existing syntax? See the examples here:
>
>> propertyChain : term '.' propertyChain
>>               | term '?.' propertyChain
>>               | term;
>
>
> Right now you can only check if property is a null when chaining to another 
> property to prevent a NPE.
>
> Maybe even better syntax would be:
>
>> value="prop?"
>> value="prop.a.b.c?"
>> value="prop?.a?.b?.c?"
>
>
> Denis
>
> Aug 23, 2011 v 1:26 PM, Igor Drobiazko:
>
>> How does it differ from existing syntax? See the examples here:
>>
>> http://tapestry.apache.org/property-expressions.html
>>
>> On Tue, Aug 23, 2011 at 1:14 PM, Denis Stepanov 
>> <[email protected]>wrote:
>>
>>> Hello,
>>>
>>> I would like to suggest a new syntax for checking if the property
>>> expression value is a null:
>>>
>>>> value="?prop"
>>>
>>>
>>> will return false if property "prop" is null or true if not
>>>
>>>> value="?prop.a.b.c"
>>>
>>>
>>> will return false if property "c" is null or true if not
>>>
>>>> value="?prop?.a?.b?.c"
>>>
>>> will return false if one of the properties is null.
>>>
>>>> value="prop"
>>>
>>>
>>> will call toString to convert it to a boolean, is not the best way how to
>>> implement a null check.
>>>
>>> We have isNotNull component, which I would like to eliminate.
>>>
>>> Denis
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>>
>> --
>> Best regards,
>>
>> Igor Drobiazko
>> http://tapestry5.de
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to