You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Henrique <hl...@yahoo.com.br> on 2008/08/04 15:32:53 UTC
ELSupport coerceToXxx and null value
Dear users and developers (at least those who check this list),
I am using Apache MyFaces 1.2, which delegates JSF EL to Commons EL. I am currently facing a tough problem with boolean values being set in a class. You see, I have a nullable boolean property in my class. This property is used (or not) in a search, so that I now have three possible values for a boolean property: true, false, and null (unset). When setting this property to the null, ELSupport.coerceToType(null, Boolean.class) is ultimately called, which returns false instead of null.
I understand that this is probably the designed behavior, but many times rules are applied differently for null values (e.g. Hibernate Criteria API search by example -- org.hibernate.criterion.Example). Is this likely to change anytime soon or should I just change my property to a three-valued enum?
ELSupport.java:
[SNIPPET]
public static final Boolean coerceToBoolean(Object obj) throws IllegalArgumentException
{
if (obj == null || "".equals(obj)) { // return null if obj == null
return Boolean.FALSE;
}
[/SNIPPET]
Best regards,
Henrique
Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses