velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <>
Subject Re: Comparing strings
Date Fri, 16 Sep 2005 10:41:31 GMT
Hi Steve,

Steve O'Hara wrote:
> A while back I chastised someone for not using proper String comparison
> operators in their templates.  I looked in the Velocity code and sure
> enough "==" operators are translated into equals. So I was looking a bit
> stupid.
> Somebody challenged me to come up with a situation where the equality
> "==" operator doesn't work with Strings.
> Well, finally, I've just found an example in my code;
>     #if ($SummarySortField==$Field.getUdmFieldName()) 
> This statement doesn't produce a true, neither does this;
>     #if ($SummarySortField==${Field.getUdmFieldName()}) 

It would be helpful to know the contents and jave class behind the
$SummarySortField ($
$Field.getUdmFieldName() ($Field.getUdmFieldName()

> But this version does:-
>     #if ($SummarySortField.equalsIgnoreCase($Field.getUdmFieldName()))

Please note that equalsIgnoreCase() is not the same as equals() ;D
You can try explicetely:

#if( $SummarySortField.equals( $Field.getUdmFieldName() ) )

Which probably will also retrun false according to the first two examples..

:) Christoph

> I thought perhaps I was going mad before when I raised this and plenty
> of people on this list questioned me, but can anyone explain this?
> Steve 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message