I’ve a java.lang.Character bean property which I’d like to compare in EL as below:
#{q.isMultiple eq 'Y'}
It does not ever evaluate true.
How is this caused and how can I solve it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In contrary to “plain Java”, whether you single or double-quote your literals in EL, they represent both
java.lang.Stringinstances. Your method is returning ajava.lang.Characterinstance, so this will never returntruein anequals()call between both instances.The solution is to change it to a
Stringorbooleanreturn type. The property nameisMultiplestrongly suggests aboolean. You only need to remove thatisfrom the property name and keep it in the getter method.An alternative is using an
enum. This would only be applicable if you have more than two states (or perhaps three, aBooleanalso includesnull).