You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ylva Degerfeldt <yl...@gmail.com> on 2008/07/30 13:32:20 UTC

Is it a bug in Struts 1.2 that you can't iterate through a java.util.Set?

Hi everyone,

I'm using Struts 1.2 (bundled with NetBeans 5.5.1) and I've noticed
that I can't iterate through a java.util.Set using the logic:iterate
tag.
The code that I've tried:

<logic:iterate collection = "skillsFound" id= "thisSkill" scope = "session">

I get this exception: javax.servlet.ServletException:
javax.servlet.jsp.JspException: Cannot create iterator for this
collection

Does anyone know if this is a bug of Struts 1.2 and if there's a later
version (not Struts 2) where it's been fixed?

I'd really appreciate an answer to this!

Thanks in advance!

/Ylva

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it a bug in Struts 1.2 that you can't iterate through a java.util.Set?

Posted by Ylva Degerfeldt <yl...@gmail.com>.
Thank you, Laurie!

But I'm going to switch to Struts 2 now so that issue is not so
important anymore.
Thanks anyway!

/Ylva

On Wed, Jul 30, 2008 at 11:11 PM, Laurie Harper <la...@holoweb.net> wrote:
> Ylva Degerfeldt wrote:
>>
>> Hi everyone,
>>
>> I'm using Struts 1.2 (bundled with NetBeans 5.5.1) and I've noticed
>> that I can't iterate through a java.util.Set using the logic:iterate
>> tag.
>> The code that I've tried:
>>
>> <logic:iterate collection = "skillsFound" id= "thisSkill" scope =
>> "session">
>>
>> I get this exception: javax.servlet.ServletException:
>> javax.servlet.jsp.JspException: Cannot create iterator for this
>> collection
>>
>> Does anyone know if this is a bug of Struts 1.2 and if there's a later
>> version (not Struts 2) where it's been fixed?
>>
>> I'd really appreciate an answer to this!
>>
>> Thanks in advance!
>>
>> /Ylva
>
> Sets are unordered, so I believe both Struts's iterate and JSTL forEach tags
> treat them as non-iterable, even though they do implement Collection. If you
> can expose skillsFound.iterator() as a scripting variable or page/request
> scoped attribute to pass into logic:iterate that might work.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it a bug in Struts 1.2 that you can't iterate through a java.util.Set?

Posted by Laurie Harper <la...@holoweb.net>.
Ylva Degerfeldt wrote:
> Hi everyone,
> 
> I'm using Struts 1.2 (bundled with NetBeans 5.5.1) and I've noticed
> that I can't iterate through a java.util.Set using the logic:iterate
> tag.
> The code that I've tried:
> 
> <logic:iterate collection = "skillsFound" id= "thisSkill" scope = "session">
> 
> I get this exception: javax.servlet.ServletException:
> javax.servlet.jsp.JspException: Cannot create iterator for this
> collection
> 
> Does anyone know if this is a bug of Struts 1.2 and if there's a later
> version (not Struts 2) where it's been fixed?
> 
> I'd really appreciate an answer to this!
> 
> Thanks in advance!
> 
> /Ylva

Sets are unordered, so I believe both Struts's iterate and JSTL forEach 
tags treat them as non-iterable, even though they do implement 
Collection. If you can expose skillsFound.iterator() as a scripting 
variable or page/request scoped attribute to pass into logic:iterate 
that might work.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org