You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Francisco Exposito Aguilera <fc...@hotmail.com> on 2006/08/01 13:43:56 UTC

html:optionsCollection problem

Hi,

I have a Bean:

package project.struts.General;
import java.util.ArrayList;
import java.util.Collection;
import java.io.*;

public class Prueba implements Serializable
{
    private Collection empresas=new ArrayList();

    public Collection getEmpresas()
    {
        empresas.add("string1");
        empresas.add("string2");
        return(empresas);
    }
}

and a jsp where I write:

<jsp:useBean id="test" class="project.struts.General.Prueba" />
<html:select property="toSelect">
    <html:optionsCollection property="empresas" name="test"/>
</html:select>

But it doesn't work. I receive the error
javax.servlet.ServletException: Cannot find bean under name 
org.apache.struts.taglib.html.BEAN

How can I solve this issue? Or what is the correct way to generate this?

Thanks in advance

_________________________________________________________________
Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN Amor 
& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349


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


Re: html:optionsCollection problem

Posted by Romu <ro...@gmail.com>.
u put the collection empresas in the request or session, try both i think .

2006/8/1, Romu <ro...@gmail.com>:
>
> <html:select   name="nameForm" property="pays" >
>
>     <html:options collection="empresas" property="value"
> labelProperty="label"/>
>
> </html:select>
>
> where pays is the property of your form
>
>
> 2006/8/1, Francisco Exposito Aguilera <fc...@hotmail.com>:
>
> > I´ve added it into a <html:form action="nameaction.do"> but I obtain the
> > error
> >
> > Cannot create iterator for project.struts.General.Prueba@3fc47c
> >
> > I´ve modified some code because I want to obtain a select with all info
> > of a
> > table which is placed in a database when the page is loaded; and this
> > page
> > only comes from a link, not from another page with an associated action
> > (therefore, nothing has been saved in session).
> >
> > public class Prueba implements Serializable
> > {
> >         private Collection empresas=new ArrayList();
> >         DTOEmpresa empresa = new DTOEmpresa();
> >
> >         public Collection getEmpresas()
> >         {
> >                 empresa.setNifEmpresa("A11111111");
> >                 empresas.add(empresa);
> >                 return(empresas);
> >         }
> >         public void setEmpresas(String empresa)
> >         {
> >                 empresas.add(empresa);
> >         }
> > }
> >
> > <jsp:useBean id="test" class="project.struts.General.Prueba"/>
> >     <html:select property="rempresa">
> >     <html:options collection="test" property="nifempresa"/>
> > </html:select>
> >
> >
> > I don´t know if I have explained my issue as I should.
> >
> > Thanks a lot.
> >
> >
> >
> > >From: Monkeyden <mo...@gmail.com>
> > >Reply-To: "Struts Users Mailing List" < user@struts.apache.org>
> > >To: "Struts Users Mailing List" <us...@struts.apache.org>
> > >Subject: Re: html:optionsCollection problem
> > >Date: Tue, 1 Aug 2006 11:13:36 -0400
> > >
> > >Looks like it may not be wrapped in a <html:form> tag in your JSP.  You
> > >probably also want a field named "toSelect", with accessor and mutators
> > in
> > >your form bean, to hold the selected value.
> > >
> > >On 8/1/06, Francisco Exposito Aguilera <fc...@hotmail.com> wrote:
> > >>
> > >>Hi,
> > >>
> > >>I have a Bean:
> > >>
> > >>package project.struts.General;
> > >>import java.util.ArrayList;
> > >>import java.util.Collection;
> > >>import java.io.*;
> > >>
> > >>public class Prueba implements Serializable
> > >>{
> > >>    private Collection empresas=new ArrayList();
> > >>
> > >>    public Collection getEmpresas()
> > >>    {
> > >>        empresas.add("string1");
> > >>         empresas.add("string2");
> > >>        return(empresas);
> > >>    }
> > >>}
> > >>
> > >>and a jsp where I write:
> > >>
> > >><jsp:useBean id="test" class=" project.struts.General.Prueba" />
> > >><html:select property="toSelect">
> > >>    <html:optionsCollection property="empresas" name="test"/>
> > >></html:select>
> > >>
> > >>But it doesn't work. I receive the error
> > >>javax.servlet.ServletException: Cannot find bean under name
> > >>org.apache.struts.taglib.html.BEAN
> > >>
> > >>How can I solve this issue? Or what is the correct way to generate
> > this?
> > >>
> > >>Thanks in advance
> > >>
> > >>_________________________________________________________________
> > >>Un amor, una aventura, compañía para un viaje. Regístrate gratis en
> > MSN
> > >>Amor
> > >>& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> >
> > _________________________________________________________________
> > Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
> > http://astrocentro.msn.es/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: html:optionsCollection problem

Posted by Francisco Exposito Aguilera <fc...@hotmail.com>.
Thanks a lot for you help!!!!! I've got it!!! At the end my problem was that 
the info didn't arrive to the session.
First I've checked if info came to the jsp with c:out and then I've use the 
html:select...




>From: Aiping <ap...@yahoo.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: html:optionsCollection problem
>Date: Tue, 1 Aug 2006 18:12:02 -0700 (PDT)
>
>Hi,
>
>   I also got the same problem, but this site offer some insights:
>
>   
>http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=008283
>
>Romu <ro...@gmail.com> wrote:
>
>
>
>
>
>
>where pays is the property of your form
>
>
>2006/8/1, Francisco Exposito Aguilera :
> >
> > I´ve added it into a but I obtain the
> > error
> >
> > Cannot create iterator for project.struts.General.Prueba@3fc47c
> >
> > I´ve modified some code because I want to obtain a select with all info 
>of
> > a
> > table which is placed in a database when the page is loaded; and this 
>page
> > only comes from a link, not from another page with an associated action
> > (therefore, nothing has been saved in session).
> >
> > public class Prueba implements Serializable
> > {
> > private Collection empresas=new ArrayList();
> > DTOEmpresa empresa = new DTOEmpresa();
> >
> > public Collection getEmpresas()
> > {
> > empresa.setNifEmpresa("A11111111");
> > empresas.add(empresa);
> > return(empresas);
> > }
> > public void setEmpresas(String empresa)
> > {
> > empresas.add(empresa);
> > }
> > }
> >
> >
> >
> >
> >
> >
> >
> > I don´t know if I have explained my issue as I should.
> >
> > Thanks a lot.
> >
> >
> >
> > >From: Monkeyden
> > >Reply-To: "Struts Users Mailing List"
> > >To: "Struts Users Mailing List"
> > >Subject: Re: html:optionsCollection problem
> > >Date: Tue, 1 Aug 2006 11:13:36 -0400
> > >
> > >Looks like it may not be wrapped in a tag in your JSP. You
> > >probably also want a field named "toSelect", with accessor and mutators
> > in
> > >your form bean, to hold the selected value.
> > >
> > >On 8/1/06, Francisco Exposito Aguilera wrote:
> > >>
> > >>Hi,
> > >>
> > >>I have a Bean:
> > >>
> > >>package project.struts.General;
> > >>import java.util.ArrayList;
> > >>import java.util.Collection;
> > >>import java.io.*;
> > >>
> > >>public class Prueba implements Serializable
> > >>{
> > >> private Collection empresas=new ArrayList();
> > >>
> > >> public Collection getEmpresas()
> > >> {
> > >> empresas.add("string1");
> > >> empresas.add("string2");
> > >> return(empresas);
> > >> }
> > >>}
> > >>
> > >>and a jsp where I write:
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>But it doesn't work. I receive the error
> > >>javax.servlet.ServletException: Cannot find bean under name
> > >>org.apache.struts.taglib.html.BEAN
> > >>
> > >>How can I solve this issue? Or what is the correct way to generate 
>this?
> > >>
> > >>Thanks in advance
> > >>
> > >>_________________________________________________________________
> > >>Un amor, una aventura, compañía para un viaje. Regístrate gratis en 
>MSN
> > >>Amor
> > >>& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
> > >>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> >
> > _________________________________________________________________
> > Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
> > http://astrocentro.msn.es/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
>
>AiPing
>
>"The greatest regrets in our lives are the risks we did not take.
>
>If you think something will make you, HAPPY, GO FOR IT.
>Remember that we pass this way only once."
>
>
>
>
>
>---------------------------------
>Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
>countries) for 2¢/min or less.

_________________________________________________________________
Descarga gratis la Barra de Herramientas de MSN 
http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH


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


Re: html:optionsCollection problem

Posted by Aiping <ap...@yahoo.com>.
Hi, 
   
  I also got the same problem, but this site offer some insights:
   
  http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=008283

Romu <ro...@gmail.com> wrote:
  





where pays is the property of your form


2006/8/1, Francisco Exposito Aguilera :
>
> I´ve added it into a but I obtain the
> error
>
> Cannot create iterator for project.struts.General.Prueba@3fc47c
>
> I´ve modified some code because I want to obtain a select with all info of
> a
> table which is placed in a database when the page is loaded; and this page
> only comes from a link, not from another page with an associated action
> (therefore, nothing has been saved in session).
>
> public class Prueba implements Serializable
> {
> private Collection empresas=new ArrayList();
> DTOEmpresa empresa = new DTOEmpresa();
>
> public Collection getEmpresas()
> {
> empresa.setNifEmpresa("A11111111");
> empresas.add(empresa);
> return(empresas);
> }
> public void setEmpresas(String empresa)
> {
> empresas.add(empresa);
> }
> }
>
> 
> 
> 
> 
>
>
> I don´t know if I have explained my issue as I should.
>
> Thanks a lot.
>
>
>
> >From: Monkeyden 
> >Reply-To: "Struts Users Mailing List" 
> >To: "Struts Users Mailing List" 
> >Subject: Re: html:optionsCollection problem
> >Date: Tue, 1 Aug 2006 11:13:36 -0400
> >
> >Looks like it may not be wrapped in a tag in your JSP. You
> >probably also want a field named "toSelect", with accessor and mutators
> in
> >your form bean, to hold the selected value.
> >
> >On 8/1/06, Francisco Exposito Aguilera wrote:
> >>
> >>Hi,
> >>
> >>I have a Bean:
> >>
> >>package project.struts.General;
> >>import java.util.ArrayList;
> >>import java.util.Collection;
> >>import java.io.*;
> >>
> >>public class Prueba implements Serializable
> >>{
> >> private Collection empresas=new ArrayList();
> >>
> >> public Collection getEmpresas()
> >> {
> >> empresas.add("string1");
> >> empresas.add("string2");
> >> return(empresas);
> >> }
> >>}
> >>
> >>and a jsp where I write:
> >>
> >>
> >>
> >> 
> >>
> >>
> >>But it doesn't work. I receive the error
> >>javax.servlet.ServletException: Cannot find bean under name
> >>org.apache.struts.taglib.html.BEAN
> >>
> >>How can I solve this issue? Or what is the correct way to generate this?
> >>
> >>Thanks in advance
> >>
> >>_________________________________________________________________
> >>Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN
> >>Amor
> >>& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
>
> _________________________________________________________________
> Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
> http://astrocentro.msn.es/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



AiPing  
 
"The greatest regrets in our lives are the risks we did not take. 

If you think something will make you, HAPPY, GO FOR IT. 
Remember that we pass this way only once." 
 



 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

Re: html:optionsCollection problem

Posted by Romu <ro...@gmail.com>.
<html:select   name="nameForm" property="pays" >

<html:options collection="empresas" property="value" labelProperty="label"/>

</html:select>

where pays is the property of your form


2006/8/1, Francisco Exposito Aguilera <fc...@hotmail.com>:
>
> I´ve added it into a <html:form action="nameaction.do"> but I obtain the
> error
>
> Cannot create iterator for project.struts.General.Prueba@3fc47c
>
> I´ve modified some code because I want to obtain a select with all info of
> a
> table which is placed in a database when the page is loaded; and this page
> only comes from a link, not from another page with an associated action
> (therefore, nothing has been saved in session).
>
> public class Prueba implements Serializable
> {
>         private Collection empresas=new ArrayList();
>         DTOEmpresa empresa = new DTOEmpresa();
>
>         public Collection getEmpresas()
>         {
>                 empresa.setNifEmpresa("A11111111");
>                 empresas.add(empresa);
>                 return(empresas);
>         }
>         public void setEmpresas(String empresa)
>         {
>                 empresas.add(empresa);
>         }
> }
>
> <jsp:useBean id="test" class="project.struts.General.Prueba"/>
>     <html:select property="rempresa">
>     <html:options collection="test" property="nifempresa"/>
> </html:select>
>
>
> I don´t know if I have explained my issue as I should.
>
> Thanks a lot.
>
>
>
> >From: Monkeyden <mo...@gmail.com>
> >Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> >To: "Struts Users Mailing List" <us...@struts.apache.org>
> >Subject: Re: html:optionsCollection problem
> >Date: Tue, 1 Aug 2006 11:13:36 -0400
> >
> >Looks like it may not be wrapped in a <html:form> tag in your JSP.  You
> >probably also want a field named "toSelect", with accessor and mutators
> in
> >your form bean, to hold the selected value.
> >
> >On 8/1/06, Francisco Exposito Aguilera <fc...@hotmail.com> wrote:
> >>
> >>Hi,
> >>
> >>I have a Bean:
> >>
> >>package project.struts.General;
> >>import java.util.ArrayList;
> >>import java.util.Collection;
> >>import java.io.*;
> >>
> >>public class Prueba implements Serializable
> >>{
> >>    private Collection empresas=new ArrayList();
> >>
> >>    public Collection getEmpresas()
> >>    {
> >>        empresas.add("string1");
> >>        empresas.add("string2");
> >>        return(empresas);
> >>    }
> >>}
> >>
> >>and a jsp where I write:
> >>
> >><jsp:useBean id="test" class="project.struts.General.Prueba" />
> >><html:select property="toSelect">
> >>    <html:optionsCollection property="empresas" name="test"/>
> >></html:select>
> >>
> >>But it doesn't work. I receive the error
> >>javax.servlet.ServletException: Cannot find bean under name
> >>org.apache.struts.taglib.html.BEAN
> >>
> >>How can I solve this issue? Or what is the correct way to generate this?
> >>
> >>Thanks in advance
> >>
> >>_________________________________________________________________
> >>Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN
> >>Amor
> >>& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
>
> _________________________________________________________________
> Horóscopo, tarot, numerología... Escucha lo que te dicen los astros.
> http://astrocentro.msn.es/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: html:optionsCollection problem

Posted by Francisco Exposito Aguilera <fc...@hotmail.com>.
I´ve added it into a <html:form action="nameaction.do"> but I obtain the 
error

Cannot create iterator for project.struts.General.Prueba@3fc47c

I´ve modified some code because I want to obtain a select with all info of a 
table which is placed in a database when the page is loaded; and this page 
only comes from a link, not from another page with an associated action 
(therefore, nothing has been saved in session).

public class Prueba implements Serializable
{
	private Collection empresas=new ArrayList();
	DTOEmpresa empresa = new DTOEmpresa();

	public Collection getEmpresas()
	{
		empresa.setNifEmpresa("A11111111");
		empresas.add(empresa);
		return(empresas);
	}
	public void setEmpresas(String empresa)
	{
		empresas.add(empresa);
	}
}

<jsp:useBean id="test" class="project.struts.General.Prueba"/>
    <html:select property="rempresa">
    <html:options collection="test" property="nifempresa"/>
</html:select>


I don´t know if I have explained my issue as I should.

Thanks a lot.



>From: Monkeyden <mo...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: "Struts Users Mailing List" <us...@struts.apache.org>
>Subject: Re: html:optionsCollection problem
>Date: Tue, 1 Aug 2006 11:13:36 -0400
>
>Looks like it may not be wrapped in a <html:form> tag in your JSP.  You
>probably also want a field named "toSelect", with accessor and mutators in
>your form bean, to hold the selected value.
>
>On 8/1/06, Francisco Exposito Aguilera <fc...@hotmail.com> wrote:
>>
>>Hi,
>>
>>I have a Bean:
>>
>>package project.struts.General;
>>import java.util.ArrayList;
>>import java.util.Collection;
>>import java.io.*;
>>
>>public class Prueba implements Serializable
>>{
>>    private Collection empresas=new ArrayList();
>>
>>    public Collection getEmpresas()
>>    {
>>        empresas.add("string1");
>>        empresas.add("string2");
>>        return(empresas);
>>    }
>>}
>>
>>and a jsp where I write:
>>
>><jsp:useBean id="test" class="project.struts.General.Prueba" />
>><html:select property="toSelect">
>>    <html:optionsCollection property="empresas" name="test"/>
>></html:select>
>>
>>But it doesn't work. I receive the error
>>javax.servlet.ServletException: Cannot find bean under name
>>org.apache.struts.taglib.html.BEAN
>>
>>How can I solve this issue? Or what is the correct way to generate this?
>>
>>Thanks in advance
>>
>>_________________________________________________________________
>>Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN
>>Amor
>>& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>

_________________________________________________________________
Horóscopo, tarot, numerología... Escucha lo que te dicen los astros. 
http://astrocentro.msn.es/


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


Re: html:optionsCollection problem

Posted by Monkeyden <mo...@gmail.com>.
Looks like it may not be wrapped in a <html:form> tag in your JSP.  You
probably also want a field named "toSelect", with accessor and mutators in
your form bean, to hold the selected value.

On 8/1/06, Francisco Exposito Aguilera <fc...@hotmail.com> wrote:
>
> Hi,
>
> I have a Bean:
>
> package project.struts.General;
> import java.util.ArrayList;
> import java.util.Collection;
> import java.io.*;
>
> public class Prueba implements Serializable
> {
>    private Collection empresas=new ArrayList();
>
>    public Collection getEmpresas()
>    {
>        empresas.add("string1");
>        empresas.add("string2");
>        return(empresas);
>    }
> }
>
> and a jsp where I write:
>
> <jsp:useBean id="test" class="project.struts.General.Prueba" />
> <html:select property="toSelect">
>    <html:optionsCollection property="empresas" name="test"/>
> </html:select>
>
> But it doesn't work. I receive the error
> javax.servlet.ServletException: Cannot find bean under name
> org.apache.struts.taglib.html.BEAN
>
> How can I solve this issue? Or what is the correct way to generate this?
>
> Thanks in advance
>
> _________________________________________________________________
> Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN
> Amor
> & Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>