commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrique <hlfso...@yahoo.com.br>
Subject ELSupport coerceToXxx and null value
Date Mon, 04 Aug 2008 13:32:53 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message