You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milson Fredy Cardona Echeverri <mi...@hotmail.com> on 2004/08/05 21:33:21 UTC

Help me with iterate tag

Hi friends

I have the following problem... desire to show the result of a SQL in a JSP 
page, the result to give in a COLLECTION, but when I call my JSP get the 
following error:

org.apache.jasper.JasperException: No collection found
at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) .....


my JSP is:

<html:form action="/listadoFormatos.do" name="listadoFormatosForm" 
type="co.edu.uco.forms.ListadoFormatosForm">
<logic:iterate id="miFila" name="listadoFormatosForm" 
property="listaFormatos">
<tr>
<td><bean:write name="miFila" property="descripcion"/></td>
<td><bean:write name="miFila" property="formato"/></td>
<td><bean:write name="miFila" property="paginaWeb"/></td>
</tr>
</logic:iterate>
-------------------------------------------------------------------------------------------------------------------------------------
my FORM is:

public class ListadoFormatosForm extends ActionForm{

//-------------------- Instance Variables
private String action = "Create";
public Collection listaFormatos = null;

//--------------------- Properties

public String getAction() {
return (this.action);
}

public void setAction(String action) {
this.action = action;
}

public Collection getListaFormatos(){
return (this.listaFormatos);
}

public void setListaFormatos(Collection collection){
System.out.println("paso FORM");
this.listaFormatos = collection;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {
this.action = "Create";
this.listaFormatos = null;
}
}

-------------------------------------------------------------------------------------------------------------------------------------

my ACTION is:

public class ListadoFormatosAction extends Action{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws java.lang.Exception{

Collection listaFormatosCollection = new ArrayList();
ListadoFormatosForm listadoFormatosForm = null;
..........

listadoFormatosForm.setListaFormatos(listaFormatosCollection);

}
-------------------------------------------------------------------------------------------------------------------------------------

and my STRUT-CONFIG is:

<form-beans>
<form-bean name="listadoFormatosForm" 
type="co.edu.uco.forms.ListadoFormatosForm"/>
</form-beans>

</action-mappings>
<action name="listadoFormatosForm" path="/listadoFormatos" scope="request"
type="co.edu.uco.action.ListadoFormatosAction">
<forward name="bien" path="/jsp/login.jsp" redirect="false" />
<forward name="mal" path="/jsp/error.jsp" redirect="false" />
</action>
</action-mappings>
-------------------------------------------------------------------------------------------------------------------------------------


Thanks in advance

Milson

PS: excuse me, my english is very bad

_________________________________________________________________
Charla con tus amigos en línea mediante MSN Messenger: 
http://messenger.latam.msn.com/


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


Re: Help me with iterate tag

Posted by Kishore Senji <ks...@gmail.com>.
No Collection found exception comes when the collection returned from
the property on the bean is null.

My guess would be in your Action, you might not be setting the
collection properly to the form.

I see this statement in your Action,
ListadoFormatosForm listadoFormatosForm = null;

How are you initializing your listadoFormatosForm, are you creating a
new ListadoFormatosForm?
If you create a new ActionForm bean, you have to set it to the request
under the name declared in the action mapping.

You can also cast the ActionForm form, that comes to the execute
method to your form, as in,
ListadoFormatosForm listadoFormatosForm = (ListadoFormatosForm) form;
then you don't have to set it to the request.

Thanks,

Kishore Senji.

On Thu, 05 Aug 2004 14:33:21 -0500, Milson Fredy Cardona Echeverri
<mi...@hotmail.com> wrote:
> Hi friends
> 
> I have the following problem... desire to show the result of a SQL in a JSP
> page, the result to give in a COLLECTION, but when I call my JSP get the
> following error:
> 
> org.apache.jasper.JasperException: No collection found
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) .....
> 
> my JSP is:
> 
> <html:form action="/listadoFormatos.do" name="listadoFormatosForm"
> type="co.edu.uco.forms.ListadoFormatosForm">
> <logic:iterate id="miFila" name="listadoFormatosForm"
> property="listaFormatos">
> <tr>
> <td><bean:write name="miFila" property="descripcion"/></td>
> <td><bean:write name="miFila" property="formato"/></td>
> <td><bean:write name="miFila" property="paginaWeb"/></td>
> </tr>
> </logic:iterate>
> -------------------------------------------------------------------------------------------------------------------------------------
> my FORM is:
> 
> public class ListadoFormatosForm extends ActionForm{
> 
> //-------------------- Instance Variables
> private String action = "Create";
> public Collection listaFormatos = null;
> 
> //--------------------- Properties
> 
> public String getAction() {
> return (this.action);
> }
> 
> public void setAction(String action) {
> this.action = action;
> }
> 
> public Collection getListaFormatos(){
> return (this.listaFormatos);
> }
> 
> public void setListaFormatos(Collection collection){
> System.out.println("paso FORM");
> this.listaFormatos = collection;
> }
> 
> public void reset(ActionMapping mapping, HttpServletRequest request) {
> this.action = "Create";
> this.listaFormatos = null;
> }
> }
> 
> -------------------------------------------------------------------------------------------------------------------------------------
> 
> my ACTION is:
> 
> public class ListadoFormatosAction extends Action{
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,
> javax.servlet.http.HttpServletRequest request,
> javax.servlet.http.HttpServletResponse response) throws java.lang.Exception{
> 
> Collection listaFormatosCollection = new ArrayList();
> ListadoFormatosForm listadoFormatosForm = null;
> ...........
> 
> listadoFormatosForm.setListaFormatos(listaFormatosCollection);
> 
> }
> -------------------------------------------------------------------------------------------------------------------------------------
> 
> and my STRUT-CONFIG is:
> 
> <form-beans>
> <form-bean name="listadoFormatosForm"
> type="co.edu.uco.forms.ListadoFormatosForm"/>
> </form-beans>
> 
> </action-mappings>
> <action name="listadoFormatosForm" path="/listadoFormatos" scope="request"
> type="co.edu.uco.action.ListadoFormatosAction">
> <forward name="bien" path="/jsp/login.jsp" redirect="false" />
> <forward name="mal" path="/jsp/error.jsp" redirect="false" />
> </action>
> </action-mappings>
> -------------------------------------------------------------------------------------------------------------------------------------
> 
> Thanks in advance
> 
> Milson
> 
> PS: excuse me, my english is very bad
> 
> _________________________________________________________________
> Charla con tus amigos en línea mediante MSN Messenger:
> http://messenger.latam.msn.com/
> 
> ---------------------------------------------------------------------
> 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