I am seeing some very unexpected behavior using OGNL in the Struts
tags.  I have two objects that contain equivalent Name objects and
when I run the following code:

<!-- Original: "<s:property value='%{originalMember.name}'/>"
(<s:property value='%{originalMember.name.class.name}'/>) -->
<!-- Current:  "<s:property value='%{currentMember.name}'/>"
(<s:property value='%{currentMember.name.class.name}'/>) -->
<!-- Equals(): <s:property
value='%{originalMember.name.equals(currentMember.name)}'/> -->
<!-- Equals:   <s:property value='%{originalMember.name ==
currentMember.name}'/> -->

it outputs the following:

<!-- Original: "CHRIS PRATT" (com.domain.model.Name) -->
<!-- Current:  "CHRIS PRATT" (com.domain.model.Name) -->
<!-- Equals(): true -->
<!-- Equals:    -->

Notice that the last statement (using the OGNL == operator) doesn't
return anything at all, which makes it useless in a <s:if> test.
According to the OGNL documentation, this should work:

"Equality is tested for as follows. If either value is null, they are
equal if and only if both are null. If they are the same object or the
equals() method says they are equal, they are equal. If they are both
Numbers, they are equal if their values as double-precision floating
point numbers are equal. Otherwise, they are not equal. These rules
make numbers compare equal more readily than they would normally, if
just using the equals method."

Does anyone know what's wrong?
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to