You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lucas Bern <lu...@yahoo.com.ar> on 2005/04/21 18:40:47 UTC

logic:iterate problem...

Hi all...

I get this exception trying to render options with logic iterate tag...

javax.servlet.jsp.JspException: Cannot create iterator for this collection

My action just get a List form a Srevice layer and store it in session scope under Globales.AreaPersonal.MODULOS_KEY.

<logic:iterate id="modulo" collection='<%=Globales.AreaPersonal.MODULOS_KEY%>' >

<option value='<%=((Contenible)modulo).getId()%>' >

<%=((Contenible)modulo).getNombre()+ " - " + ((Contenible)modulo).getTitulo()%>

</option>

</logic:iterate>

i wish someone help me...

thanks!

Lucas



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

Re: logic:iterate problem...

Posted by Erik Weber <er...@mindspring.com>.
Hmm I didn't even notice that.

However, this is the section of code that throws that Exception (from 
1.2.4 src):

    /**
     * Construct an iterator for the specified collection, and begin
     * looping through the body once per element.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {

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

        if (collection == null) {
            JspException e = new 
JspException(messages.getMessage("iterate.collection"));
            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }

So I'm not sure.

Erik



Michael Jouravlev wrote:

>Looks like you are trying to iterate over string.
>
>How about this:
>
><logic:iterate id="modulo" 
>  collection='<%=(List)
>session.getAttribute(Globales.AreaPersonal.MODULOS_KEY)%>' >
>
>Michael.
>
>On 4/21/05, Lucas Bern <lu...@yahoo.com.ar> wrote:
>  
>
>>Hi all...
>>
>>I get this exception trying to render options with logic iterate tag...
>>
>>javax.servlet.jsp.JspException: Cannot create iterator for this collection
>>
>>My action just get a List form a Srevice layer and store it in session scope under Globales.AreaPersonal.MODULOS_KEY.
>>
>><logic:iterate id="modulo" collection='<%=Globales.AreaPersonal.MODULOS_KEY%>' >
>>
>><option value='<%=((Contenible)modulo).getId()%>' >
>>
>><%=((Contenible)modulo).getNombre()+ " - " + ((Contenible)modulo).getTitulo()%>
>>
>></option>
>>
>></logic:iterate>
>>
>>i wish someone help me...
>>
>>thanks!
>>
>>Lucas
>>
>>
>>__________________________________________________
>>Correo Yahoo!
>>Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
>>¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
>>
>>    
>>
>
>---------------------------------------------------------------------
>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: logic:iterate problem...

Posted by Michael Jouravlev <jm...@gmail.com>.
Looks like you are trying to iterate over string.

How about this:

<logic:iterate id="modulo" 
  collection='<%=(List)
session.getAttribute(Globales.AreaPersonal.MODULOS_KEY)%>' >

Michael.

On 4/21/05, Lucas Bern <lu...@yahoo.com.ar> wrote:
> 
> Hi all...
> 
> I get this exception trying to render options with logic iterate tag...
> 
> javax.servlet.jsp.JspException: Cannot create iterator for this collection
> 
> My action just get a List form a Srevice layer and store it in session scope under Globales.AreaPersonal.MODULOS_KEY.
> 
> <logic:iterate id="modulo" collection='<%=Globales.AreaPersonal.MODULOS_KEY%>' >
> 
> <option value='<%=((Contenible)modulo).getId()%>' >
> 
> <%=((Contenible)modulo).getNombre()+ " - " + ((Contenible)modulo).getTitulo()%>
> 
> </option>
> 
> </logic:iterate>
> 
> i wish someone help me...
> 
> thanks!
> 
> Lucas
> 
> 
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
>

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


Re: logic:iterate problem...

Posted by Jeff Beal <jb...@gmail.com>.
>From http://struts.apache.org/userGuide/struts-logic.html#iterate:

collection: A runtime expression that evaluates to a collection

<%=Globales.AreaPersonal.MODULOS_KEY%> probably evaluates to a String.

What you need is

name='<%=Globales.AreaPersonal.MODULOS_KEY%>'

On 4/21/05, Lucas Bern <lu...@yahoo.com.ar> wrote:
> 
> My action just get a List form a Srevice layer and store it in session scope under Globales.AreaPersonal.MODULOS_KEY.
> 
> <logic:iterate id="modulo" collection='<%=Globales.AreaPersonal.MODULOS_KEY%>'

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


Re: logic:iterate problem...

Posted by Erik Weber <er...@mindspring.com>.
I think your List reference is probably null.

Also, have you looked at html:options and html:optionsCollection?

Erik



Lucas Bern wrote:

>Hi all...
>
>I get this exception trying to render options with logic iterate tag...
>
>javax.servlet.jsp.JspException: Cannot create iterator for this collection
>
>My action just get a List form a Srevice layer and store it in session scope under Globales.AreaPersonal.MODULOS_KEY.
>
><logic:iterate id="modulo" collection='<%=Globales.AreaPersonal.MODULOS_KEY%>' >
>
><option value='<%=((Contenible)modulo).getId()%>' >
>
><%=((Contenible)modulo).getNombre()+ " - " + ((Contenible)modulo).getTitulo()%>
>
></option>
>
></logic:iterate>
>
>i wish someone help me...
>
>thanks!
>
>Lucas
>
>
>
>__________________________________________________
>Correo Yahoo!
>Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
>¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
>  
>

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