jsr341-experts@el-spec.java.net

[jsr341-experts] Re: Type coercion in EL

From: Kin-man Chung <kinman.chung_at_oracle.com>
Date: Mon, 07 May 2012 13:27:31 -0700

On 05/07/12 11:53, Mark Thomas wrote:
> On 24/04/2012 20:06, Kin-man Chung wrote:
>
>> Dear experts,
>>
>> There have been several requests for changing the coercion rules in EL,
>> when the sources is a null or an empty string. See
>>
>> http://java.net/jira/browse/JSP_SPEC_PUBLIC-184
>> http://java.net/jira/browse/UEL-12
>> http://java.net/jira/browse/UEL-13
>>
>> I think we should address this issue in EL 3.0.
>>
>> Specifically, we should make the distinction between a target type of
>> say int vs. Integer. A null should be coerced to a 0 in the formal
>> case, and remains a null in the later.
>>
>> Similarly, if the target is a String, a null should not be coerced to
>> "", but should remains a null.
>>
>> This would break backward compatibility, but nobody seems to want the
>> current behavior, and this is really a bug.
>>
> As long as there is a way for folks who actually want the current
> behaviour revert to it without re-writing their entire app then I am
> fine with this change.
>
>
The spec will not have a configuration option to do this, but that
shouldn't prevent an implementation to have such option.

Kin-man
> Mark
>
>
>> We have also introduced custom pluggable type converter in EL 3.0. The
>> currently proposal adds a new field in the ELContext. Though it would
>> work, I am leaning more to adding a new method in the ELResolver, such as
>>
>> Object converType(Object obj, Class<?> targetType);
>>
>> The reason for putting it in the ELResolver is that it allows for
>> addition of multiple ELResolvers to handle multiple custom type
>> converters, and that ELResolver seems to be a more suitable home for it.
>>
>> If there are comments or questions, please let me know.
>>
>> Kin-man
>>
>