jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
68 stars 49 forks source link

null and empty string #13

Closed glassfishrobot closed 11 years ago

glassfishrobot commented 14 years ago

in com.sun.el.lang.ELSupport.coerceToString() I noticed that a in case of a null String, the method returns "";

The way down. In the converter: if (patternExpression != null)

{ pattern = (String) ELUtils.evaluateValueExpression(patternExpression, elContext); }

in

com.sun.faces.el.ELUtils.evaluateValueExpression() (expectedType == String... for the pattern)

if (this.expectedType != null)

{ return ELSupport.coerceToType(value, this.expectedType); }

coerceToType CALLs the coerceToString()

public final static String coerceToString(final Object obj) { if (obj == null) { return ""; ... }

That is because: Unified EL Spec says:

If A is String: return A Otherwise, if A is null: return ""

Isn't that crazy ? ------- Additional comments from rogerk Fri Aug 22 15:50:37 +0000 2008 -------

Status Whiteboard ------- Additional comments from edburns Mon Aug 25 12:52:18 +0000 2008 -------

Spec work checked in. re-assigning to Ryan. ------- Additional comments from rlubke Thu Aug 28 21:30:11 +0000 2008 -------

Created an attachment (id=132) Proposed changes (ver 1) ------- Additional comments from rlubke Thu Aug 28 21:32:05 +0000 2008 -------

Ed, Roger,

I've attached an alternate proposal to the one proposed to the EG.

This solves the original intent of this issue without the need for additional FacesContext ThreadLocal lookups and for another case regarding ValueChangeListeners (described within the change bundle).

Thoughts? Comments? ------- Additional comments from edburns Fri Aug 29 17:34:26 +0000 2008 -------

r=edburns ------- Additional comments from rlubke Fri Aug 29 18:06:09 +0000 2008 -------

Changes applied to the trunk. ------- Additional comments from edburns Fri Aug 29 18:47:40 +0000 2008 -------

Updated javadoc and spec. CONDITIONALLY Marking FIXED. ------- Additional comments from edburns Fri Aug 29 18:53:23 +0000 2008 -------

Created an attachment (id=133) Spec fix, look at validate() method. ------- Additional comments from mwessendorf Mon Sep 8 18:45:49 +0000 2008 -------

This is only the half part of the bug fix, right ? still the Unified EL does treat NULL as ""

=> <f:convertDateTime pattern="#

{thisValueWillReturnAsNull}

" />

the actual pattern is ""-

Perhaps we should move this to the unifed EL ? Or are there seriously no changes for JavaEE 6 at all ------- Additional comments from mwessendorf Wed Oct 15 08:04:17 +0000 2008 -------

and a similar issues as well: http://www.nabble.com/myfaces---bean-properties-are-set-with-0.0-instead-of-null- td19980936.html ------- Additional comments from edburns Wed Oct 15 11:32:26 +0000 2008 -------

You're talking about 1.18.2, right?

EL> Coerce A to String EL> If A is String: return A EL> Otherwise, if A is null: return "" EL> Otherwise, if A is Enum, return A.name() EL> Otherwise, if A.toString() throws an exception, error EL> Otherwise, return A.toString()

I expect there are some contexts in which this is the correct behavior. In any case, making a brute-force change to 1.18.2 would be sure to introduce bacwards compatibility problems. Matthias, can you please suggest how we can change 1.18.2 without breaking backwards compatibility?

Pete, I'd love to hear your suggestions on this as well.

Ed ------- Additional comments from edburns Wed Oct 15 13:43:13 +0000 2008 -------

Change target milestone to 2.0 ------- Additional comments from edburns Thu Sep 24 15:34:46 +0000 2009 -------

move to 2.1 ------- Additional comments from edburns Tue Nov 24 15:42:42 +0000 2009 -------

Prepare to delete "implementation" subcomponent. ------- Additional comments from edburns Mon Dec 14 16:59:32 +0000 2009 -------

Move these to unscheduled because we need to target them correctly. 2.next isn't specific enough. ------- Additional comments from rogerk Fri Mar 5 15:17:01 +0000 2010 -------

cat2

Environment

Operating System: All Platform: Macintosh URL: https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=322

Affected Versions

[current]

glassfishrobot commented 6 years ago
glassfishrobot commented 14 years ago

@glassfishrobot Commented Reported by @edburns

glassfishrobot commented 11 years ago

@glassfishrobot Commented kchung said: Changing the behavior of converting null to String will be backward incompatible. However, EL 3.0 custom type conversions can be used to modify the standard conversion.

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA UEL-13

glassfishrobot commented 11 years ago

@glassfishrobot Commented Marked as won't fix on Thursday, March 14th 2013, 11:15:22 am