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
references:
$SummarySortField ($SummarySortField.class.name)
$Field.getUdmFieldName() ($Field.getUdmFieldName().class.name)
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]