I'm trying to compare two different object in JSF. A String and an Integer, of cours it don't work...
//myVar ==> Integer object
//myVar2 ==> String
<c:if test="${myVar == myVar2}">
YES!!!!!!!!
</c:if>
I try with myVar.toString but it's wrong. So how to do it ?
Thank's
I'm trying to compare two different object in JSF. A String and an Integer, of cours it don't work...
That does not sound right - I would check the values. For the bean:
public class CoercedBean {
public int getValueAsInt() {
return 123;
}
public String getValueAsString() {
return "123";
}
}
...these example expressions evaluate to true:
${coercedBean.valueAsInt == coercedBean.valueAsString}
<h:outputText style="color: blue"
value="#{coercedBean.valueAsInt eq coercedBean.valueAsString}" />
The JSP 2.1 (EL) spec says of evaluating equality:
A {==,!=,eq,ne} BIf A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long, apply operator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With