[ http://mc4j.org/jira/browse/STS-314?page=comments#action_10569 ]
Aaron Porter commented on STS-314:
----------------------------------
NPE occurs on empty collection as well.
This works well for me:
Index:
/home/aaron/workspace/stripes/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
===================================================================
---
/home/aaron/workspace/stripes/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
(revision 476)
+++
/home/aaron/workspace/stripes/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
(working copy)
@@ -96,7 +96,7 @@
}
/** Internal list of entires that is assembled from the items in the
collection. */
- private List<Entry> entries;
+ private List<Entry> entries = new LinkedList<Entry>();
/** Sets the collection that will be used to generate options. */
public void setCollection(Collection collection) {
@@ -161,7 +161,6 @@
* @param value the actual value for the option
*/
protected void addEntry(Object item, Object label, Object value) {
- if (this.entries == null) this.entries = new LinkedList<Entry>();
this.entries.add(new Entry(item, label, value));
}
@@ -175,6 +174,9 @@
* not present on the beans in the collection
*/
public int doStartTag() throws JspException {
+ if (this.collection == null)
+ return SKIP_BODY;
+
String labelProperty = getLabel();
String valueProperty = getValue();
> stripes:options-collection null Collections
> -------------------------------------------
>
> Key: STS-314
> URL: http://mc4j.org/jira/browse/STS-314
> Project: Stripes
> Issue Type: Improvement
> Components: Tag Library
> Affects Versions: Release 1.4.2
> Environment: All
> Reporter: Gregg Bolinger
> Assigned To: Tim Fennell
> Priority: Minor
>
> It would be nice if the options-collection tag handled null Collections.
> Currently, you have to wrap the tag declaration around some sort of check
> like:
> <c:if test="${someCollection != null}">
> <stripes:options-collection...../>
> </c:if>
> While this is fairly easy and straightfoward, it's more verbose than need be.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development