Bug 18816 - org.apache.taglibs.standard.lang.jstl.EmptyOperator.apply(...) bug
Summary: org.apache.taglibs.standard.lang.jstl.EmptyOperator.apply(...) bug
Status: RESOLVED FIXED
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0.2
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 14:58 UTC by Mike Lissick
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
treats Collections instead of Lists or Maps (891 bytes, patch)
2003-07-01 07:47 UTC, gregory_lardiere
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Lissick 2003-04-08 14:58:56 UTC
The EmptyOperator doesn't work for all objects implementing Collection as the 
specification requires.  The apply(...) method only checks null, empty String, 
zero-length array, empty List or empty Map.  Therefore, it doesn't work on a 
Set.  Looking at the code, it appears that the Map and List specific logic 
could be replaced with Collection-specific logic, which would then support Set.

This is also true of v 1.0.3 according to the source code I downloaded minutes 
ago (today is 4/8/2003).

If you have any questions regardinging this, don't hesitate to contact me at 
mlissick@yahoo.com

Best Regards,
Mike Lissick
Comment 1 gregory_lardiere 2003-07-01 07:47:14 UTC
Created attachment 7035 [details]
treats Collections instead of Lists or Maps
Comment 2 Pierre Delisle 2003-08-02 02:03:15 UTC
JSTL 1.0 specifies the following:

A.3.8 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value is
null or empty.
To evaluate empty A
- If A is null, return true,
- Otherwise, if A is the empty string, then return true.
- Otherwise, if A is an empty array, then return true.
- Otherwise, if A is an empty Map, return true
- Otherwise, if A is an empty List, return true,
- Otherwise return false.

Unfortunately, the case where A is a Collection was left out in 1.0.

However, this has been fixed in the JSP 2.0 spec (which now owns the EL),
and is therefore available with JSTL 1.1.

PROPOSED FINAL DRAFT 3
JSP.2.3.7 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value
is null or empty.
To evaluate empty A
EXPRESSION LANGUAGE 1-72
- If A is null, return true,
- Otherwise, if A is the empty string, then return true.
- Otherwise, if A is an empty array, then return true.
- Otherwise, if A is an empty Map, return true,
- Otherwise, if A is an empty Collection, return true,
- Otherwise return false.