DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15159>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15159

Iterate tag collection attribute does not work

           Summary: Iterate tag collection attribute does not work
           Product: Struts
           Version: 1.1 Beta 2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


If you try to iterate over an array of objects that has been stored into a 
context (request, page, session) using the iterate tag like this 
<logic:iterate id="elem" collection="myArray"> will fail with a "cant get 
iterator" message.

When I look in the source code for the iterator tag I can see that startTag() 
method starts with:

// Acquire the collection we are going to iterate over
        Object collection = this.collection;
        if (collection == null)
            collection =
                RequestUtils.lookup(pageContext, name, property, scope);

This means that if the collection attribute is supplied as a String the actual
String value will be treated as a collection (and fail) instead of used as a key
to find the corresponding collection/array in the context.

I suggest changing the code above to something like:

// Acquire the collection we are going to iterate over
        Object collection = this.collection;
        if (collection == null)
            collection =
                RequestUtils.lookup(pageContext, name, property, scope);
        else 
            collection =
                RequestUtils.lookup(pageContext, this.collection.toString(), 
scope);

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to