You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Puneet Lakhina <pu...@gmail.com> on 2006/08/01 06:06:42 UTC

DHTML and Struts

I have a set of text fields on a form. but the number of the text fields il
need is soemthing that depends on the user using the application.
So i have used DHTML to dynamically add a text field to the form. ofcourse i
have used normal html tags for the dynamically added text field.

But the problem is that this data never reaches my form bean. Is it not
possible to use dhtml in combination with struts??

thanks
-- 
Puneet

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
>
>

Re: DHTML and Struts

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Yeah, leave it to IE to not work with DOM-compliant code :)  I guess I 
only tried it in FF, which is odd since I don't generally use FF (it was 
probably just open at the time!).  Glad you got it working!

Frank

Puneet Lakhina wrote:
> On 8/3/06, Puneet Lakhina <pu...@gmail.com> wrote:
>>
>>
>>
>>
>> Any form elements created dynamically on the client-side will have no
>> > intrinsic link to the ActionForm.  However, this is not necessarily a
>> > problem... imagine if your ActionForm has this in it:
>> >
>> > private String firstName;
>> > public void setFirstName(String inFirstName) {
>> >   firstName = inFirstName;
>> > }
>> > public String getFirstName() {
>> >   return firstName;
>> > }
>> >
>> > What happens if your JSP *DOES NOT* include this form field?  Obviously
>> > that will be just fine, Struts won't complain.
>> >
>> > Now, what happens if you dynamically add that field to your HTML form
>> > via
>> > JavaScript, and then submit the form?  Again, this will be just fine,
>> > Struts will happily populate the firstName field in the ActionForm.  It
>> > doesn't matter that it wasn't there when the HTML for the page was
>> > originally rendered by the JSP.
>> >
>> > In the case of indexed properties, the same is true... if you
>> > dynamically
>> > add a field to the HTML form, so long as the name follows the index
>> > naming
>> > paradigm, it will be populated in the ActionForm when submitted.
>> >
>> > The code you have here looks basically correct, with one possible
>> > exception... setting innerHTML doesn't necessarily add anything to the
>> > DOM.  So, when the form is submitted, the fields you dynamically added
>> > may
>> > not be sent (I believe it will work in some browsers, but not in
>> > others...
>> > I'd have to go test to verify this, but that's what's in my memory).
>> > Instead, you should use DOM methods to create your new field and append
>> > it
>> > to the form, that should alleviate that problem.  This is generally the
>> > preferred method to work with dynamic content anyway.  So, your add
>> > method
>> > should be something like
>> >
>> > function add() {
>> >   var newField = document.createElement("input");
>> >   newField.type = "text";
>> >   newField.name = "foo[" + count + "]";
>> >   var newCell = document.createElement("td");
>> >   newCell.appendChild (newField);
>> >   var newRow = document.createElement("tr");
>> >   newRow.appendChild(newCell);
>> >   var theTable = document.getElementById("t1");
>> >   theTable.appendChild(newRow);
>> >   count++;
>> > }
>> >
>> > Frank
>> >
>>
>> ok this is actually fanatstic!!!!Thanks a tonne. But small problem, this
>> thing doesnt work on IE(and yes, like everyone, my target audience 
>> also has
>> it as there primary browser). I mean the rows dont get added to the 
>> page. It
>> stays static, doesnt throw any javascript errors either.. could you 
>> test it
>> out on your side??
>> I have yahoo toolbar on my IE. could that be causing the problem??
>> I have IE 6 and Firefox 1.5.0.6
>> It works easily on firefox.
>>
>> -- 
>> Puneet
>>
> 
> ok.. got it to work on IE too. Some javascript trial and error.
> This thing works, why and how the earlier thing doesnt work on IE will take
> time to figure out
> 
> tha javascript function
> count=1;//one cell is already there using
> function add() {
> var theTable = document.getElementById("t1");
> var row = theTable.insertRow(count);
> var newField = document.createElement("input");
> newField.type = "text";
> newField.name = "list[" + count + "]";
> var newCell = row.insertCell(0);/*you could have some kind of count here if
> u want multiple cells*/
> newCell.appendChild(newField);
> count++;
> }
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
  (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
  Supplying the wheel, so you don't have to reinvent it!

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


Re: DHTML and Struts

Posted by Puneet Lakhina <pu...@gmail.com>.
On 8/3/06, Puneet Lakhina <pu...@gmail.com> wrote:
>
>
>
>
> Any form elements created dynamically on the client-side will have no
> > intrinsic link to the ActionForm.  However, this is not necessarily a
> > problem... imagine if your ActionForm has this in it:
> >
> > private String firstName;
> > public void setFirstName(String inFirstName) {
> >   firstName = inFirstName;
> > }
> > public String getFirstName() {
> >   return firstName;
> > }
> >
> > What happens if your JSP *DOES NOT* include this form field?  Obviously
> > that will be just fine, Struts won't complain.
> >
> > Now, what happens if you dynamically add that field to your HTML form
> > via
> > JavaScript, and then submit the form?  Again, this will be just fine,
> > Struts will happily populate the firstName field in the ActionForm.  It
> > doesn't matter that it wasn't there when the HTML for the page was
> > originally rendered by the JSP.
> >
> > In the case of indexed properties, the same is true... if you
> > dynamically
> > add a field to the HTML form, so long as the name follows the index
> > naming
> > paradigm, it will be populated in the ActionForm when submitted.
> >
> > The code you have here looks basically correct, with one possible
> > exception... setting innerHTML doesn't necessarily add anything to the
> > DOM.  So, when the form is submitted, the fields you dynamically added
> > may
> > not be sent (I believe it will work in some browsers, but not in
> > others...
> > I'd have to go test to verify this, but that's what's in my memory).
> > Instead, you should use DOM methods to create your new field and append
> > it
> > to the form, that should alleviate that problem.  This is generally the
> > preferred method to work with dynamic content anyway.  So, your add
> > method
> > should be something like
> >
> > function add() {
> >   var newField = document.createElement("input");
> >   newField.type = "text";
> >   newField.name = "foo[" + count + "]";
> >   var newCell = document.createElement("td");
> >   newCell.appendChild (newField);
> >   var newRow = document.createElement("tr");
> >   newRow.appendChild(newCell);
> >   var theTable = document.getElementById("t1");
> >   theTable.appendChild(newRow);
> >   count++;
> > }
> >
> > Frank
> >
>
> ok this is actually fanatstic!!!!Thanks a tonne. But small problem, this
> thing doesnt work on IE(and yes, like everyone, my target audience also has
> it as there primary browser). I mean the rows dont get added to the page. It
> stays static, doesnt throw any javascript errors either.. could you test it
> out on your side??
> I have yahoo toolbar on my IE. could that be causing the problem??
> I have IE 6 and Firefox 1.5.0.6
> It works easily on firefox.
>
> --
> Puneet
>

ok.. got it to work on IE too. Some javascript trial and error.
This thing works, why and how the earlier thing doesnt work on IE will take
time to figure out

tha javascript function
count=1;//one cell is already there using
function add() {
var theTable = document.getElementById("t1");
var row = theTable.insertRow(count);
var newField = document.createElement("input");
 newField.type = "text";
 newField.name = "list[" + count + "]";
 var newCell = row.insertCell(0);/*you could have some kind of count here if
u want multiple cells*/
 newCell.appendChild(newField);
 count++;
}

-- 
Puneet

Re: DHTML and Struts

Posted by Puneet Lakhina <pu...@gmail.com>.
Any form elements created dynamically on the client-side will have no
> intrinsic link to the ActionForm.  However, this is not necessarily a
> problem... imagine if your ActionForm has this in it:
>
> private String firstName;
> public void setFirstName(String inFirstName) {
>   firstName = inFirstName;
> }
> public String getFirstName() {
>   return firstName;
> }
>
> What happens if your JSP *DOES NOT* include this form field?  Obviously
> that will be just fine, Struts won't complain.
>
> Now, what happens if you dynamically add that field to your HTML form via
> JavaScript, and then submit the form?  Again, this will be just fine,
> Struts will happily populate the firstName field in the ActionForm.  It
> doesn't matter that it wasn't there when the HTML for the page was
> originally rendered by the JSP.
>
> In the case of indexed properties, the same is true... if you dynamically
> add a field to the HTML form, so long as the name follows the index naming
> paradigm, it will be populated in the ActionForm when submitted.
>
> The code you have here looks basically correct, with one possible
> exception... setting innerHTML doesn't necessarily add anything to the
> DOM.  So, when the form is submitted, the fields you dynamically added may
>
> not be sent (I believe it will work in some browsers, but not in others...
> I'd have to go test to verify this, but that's what's in my memory).
> Instead, you should use DOM methods to create your new field and append it
>
> to the form, that should alleviate that problem.  This is generally the
> preferred method to work with dynamic content anyway.  So, your add method
> should be something like
>
> function add() {
>   var newField = document.createElement("input");
>   newField.type = "text";
>   newField.name = "foo[" + count + "]";
>   var newCell = document.createElement("td");
>   newCell.appendChild (newField);
>   var newRow = document.createElement("tr");
>   newRow.appendChild(newCell);
>   var theTable = document.getElementById("t1");
>   theTable.appendChild(newRow);
>   count++;
> }
>
> Frank
>

ok this is actually fanatstic!!!!Thanks a tonne. But small problem, this
thing doesnt work on IE(and yes, like everyone, my target audience also has
it as there primary browser). I mean the rows dont get added to the page. It
stays static, doesnt throw any javascript errors either.. could you test it
out on your side??
I have yahoo toolbar on my IE. could that be causing the problem??
I have IE 6 and Firefox 1.5.0.6
It works easily on firefox.

-- 
Puneet

Re: DHTML and Struts

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Any form elements created dynamically on the client-side will have no
intrinsic link to the ActionForm.  However, this is not necessarily a
problem... imagine if your ActionForm has this in it:

private String firstName;
public void setFirstName(String inFirstName) {
  firstName = inFirstName;
}
public String getFirstName() {
  return firstName;
}

What happens if your JSP *DOES NOT* include this form field?  Obviously
that will be just fine, Struts won't complain.

Now, what happens if you dynamically add that field to your HTML form via
JavaScript, and then submit the form?  Again, this will be just fine,
Struts will happily populate the firstName field in the ActionForm.  It
doesn't matter that it wasn't there when the HTML for the page was
originally rendered by the JSP.

In the case of indexed properties, the same is true... if you dynamically
add a field to the HTML form, so long as the name follows the index naming
paradigm, it will be populated in the ActionForm when submitted.

The code you have here looks basically correct, with one possible
exception... setting innerHTML doesn't necessarily add anything to the
DOM.  So, when the form is submitted, the fields you dynamically added may
not be sent (I believe it will work in some browsers, but not in others...
I'd have to go test to verify this, but that's what's in my memory). 
Instead, you should use DOM methods to create your new field and append it
to the form, that should alleviate that problem.  This is generally the
preferred method to work with dynamic content anyway.  So, your add method
should be something like

function add() {
  var newField = document.createElement("input");
  newField.type = "text";
  newField.name = "foo[" + count + "]";
  var newCell = document.createElement("td");
  newCell.appendChild(newField);
  var newRow = document.createElement("tr");
  newRow.appendChild(newCell);
  var theTable = document.getElementById("t1");
  theTable.appendChild(newRow);
  count++;
}

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, August 2, 2006 12:48 am, Puneet Lakhina wrote:
>>
>>
>> you were hung up (maybe I read into your question incorrectly).  So are
>> you actually hung up on the JavaScript to dynamically add fields?
>
>
>
> Yes, i am able to add text fields to my page, but I dont know what all
> attributes to specify in the input tag so that my user bean recieves the
> values from the dynamically added text fields.
>
> i.e.
> <script language="javascript>
> count=1;
> function add()
> {
> var row = document.getElementById('t1').insertRow(count);
> var cell=row.insertCell(0);
> cell.innerHTML="<input type=text name=foo[" + count + "]" +  "/>
> count++;
> }
> </script>
> <input type="button" onclick="add()" />
> <table id="t1">
> <tr>
>   <td>
>     <html:text property="foo[0]" >
>   </td>
>  </tr>
> </table>
> </table>
>
> --
> Puneet
>


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


Re: DHTML and Struts

Posted by Puneet Lakhina <pu...@gmail.com>.
>
>
> you were hung up (maybe I read into your question incorrectly).  So are
> you actually hung up on the JavaScript to dynamically add fields?



Yes, i am able to add text fields to my page, but I dont know what all
attributes to specify in the input tag so that my user bean recieves the
values from the dynamically added text fields.

i.e.
<script language="javascript>
count=1;
function add()
{
var row = document.getElementById('t1').insertRow(count);
var cell=row.insertCell(0);
cell.innerHTML="<input type=text name=foo[" + count + "]" +  "/>
count++;
}
</script>
<input type="button" onclick="add()" />
<table id="t1">
<tr>
  <td>
    <html:text property="foo[0]" >
  </td>
 </tr>
</table>
</table>

-- 
Puneet

Re: DHTML and Struts

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Tue, August 1, 2006 5:05 am, Puneet Lakhina wrote:
>>
>>
>> http://struts.apache.org/1.x/userGuide/building_controller.html
>>
>> Specifically, section 4.3.3 Map-backed ActionForms.
>
>
> have already read that. But in that the page is generated dynamically, it
> doesnt change once rendered on the client, which is what I want to do.

Correct, but the "tricky" part is when the submission hits the ActionForm,
which is where that information comes into play.  That's where I thought
you were hung up (maybe I read into your question incorrectly).  So are
you actually hung up on the JavaScript to dynamically add fields?

> Puneet

Frank

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


html:optionsCollection problem

Posted by Francisco Exposito Aguilera <fc...@hotmail.com>.
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: DHTML and Struts

Posted by Puneet Lakhina <pu...@gmail.com>.
>
>
> http://struts.apache.org/1.x/userGuide/building_controller.html
>
> Specifically, section 4.3.3 Map-backed ActionForms.


have already read that. But in that the page is generated dynamically, it
doesnt change once rendered on the client, which is what I want to do.

-- 
Puneet

Re: DHTML and Struts

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi,

Have a look here:

http://struts.apache.org/1.x/userGuide/building_controller.html

Specifically, section 4.3.3 Map-backed ActionForms.

Frank

Puneet Lakhina wrote:
> I have a set of text fields on a form. but the number of the text fields il
> need is soemthing that depends on the user using the application.
> So i have used DHTML to dynamically add a text field to the form. 
> ofcourse i
> have used normal html tags for the dynamically added text field.
> 
> But the problem is that this data never reaches my form bean. Is it not
> possible to use dhtml in combination with struts??
> 
> thanks

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
  (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
  Supplying the wheel, so you don't have to reinvent it!

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