You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by kothapallibc <ko...@yahoo.com> on 2002/02/08 14:08:52 UTC
Can nested beans be arrays in Struts1.0?
Hi all,
I'm a newbie to Struts. I'm trying with 1.0 release.
My FormBean is follows...
public class MonkeyForm extends ActionForm {
private Monkey[] monkey = new Monkey[5];
public Monkey[] getMonkey() { return this.monkey; }
public void setMonkey(Monkey monkey[]) {this.monkey = monkey;}
}
public class Monkey{
private String name;
private String age;
//Get and set methods are here
}
Assuming that I don't want to use Struts tab libraries, how should be
the field names in HTML? Am I right to have them like this?
<input type="text" name="monkey[0].name" >
<input type="text" name="monkey[0].age" >
<input type="text" name="monkey[1].name">
<input type="text" name="monkey[1].age">
Somehow, these values are not populated in the form bean.
Do I have to specify Monkey bean anywhere in struts-config?
It works with simple arrays and when the nested bean is not an array,
but it doesn't if the nested bean is an array. Am I doing something
wrong?
Regards,
Choudary.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Can nested beans be arrays in Struts1.0?
Posted by Arron Bates <ar...@pacific.net.au>.
I think that a part of the problem is that you might have tried to run
before you were walking. :)
The automatic population will only ever come from Struts tags in one
form or another.
I don't understand why you want to go back.
You've obviously been through the Nested Extension tutorial, and seen
how cool the Struts tags are :)
Arron.
>--- kothapallibc <ko...@yahoo.com> wrote:
>
>>Hi all,
>>I'm a newbie to Struts. I'm trying with 1.0 release.
>>
>>My FormBean is follows...
>>
>>public class MonkeyForm extends ActionForm {
>> private Monkey[] monkey = new Monkey[5];
>> public Monkey[] getMonkey() { return this.monkey; }
>> public void setMonkey(Monkey monkey[]) {this.monkey = monkey;}
>>}
>>
>>public class Monkey{
>> private String name;
>> private String age;
>> //Get and set methods are here
>>}
>>
>>Assuming that I don't want to use Struts tab libraries, how should be
>>the field names in HTML? Am I right to have them like this?
>>
>> <input type="text" name="monkey[0].name" >
>> <input type="text" name="monkey[0].age" >
>> <input type="text" name="monkey[1].name">
>> <input type="text" name="monkey[1].age">
>>
>>Somehow, these values are not populated in the form bean.
>>Do I have to specify Monkey bean anywhere in struts-config?
>>
>>It works with simple arrays and when the nested bean is not an array,
>>but it doesn't if the nested bean is an array. Am I doing something
>>wrong?
>>
>>Regards,
>>Choudary.
>>
>>
>>--
>>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Send FREE Valentine eCards with Yahoo! Greetings!
>http://greetings.yahoo.com
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Can nested beans be arrays in Struts1.0?
Posted by Keith Bacon <ke...@yahoo.com>.
but use the struts <html:text tag!
Then struts will move data between the formBean & your form for you.
Otherwise you have to
<jsp: useBean .....
<% String thingToDisplay = = formBean.getMonkey[0].getAge() %>
etc.
struts was invented to save us that pain. The tags are great!
K.
--- kothapallibc <ko...@yahoo.com> wrote:
> Hi all,
> I'm a newbie to Struts. I'm trying with 1.0 release.
>
> My FormBean is follows...
>
> public class MonkeyForm extends ActionForm {
> private Monkey[] monkey = new Monkey[5];
> public Monkey[] getMonkey() { return this.monkey; }
> public void setMonkey(Monkey monkey[]) {this.monkey = monkey;}
> }
>
> public class Monkey{
> private String name;
> private String age;
> //Get and set methods are here
> }
>
> Assuming that I don't want to use Struts tab libraries, how should be
> the field names in HTML? Am I right to have them like this?
>
> <input type="text" name="monkey[0].name" >
> <input type="text" name="monkey[0].age" >
> <input type="text" name="monkey[1].name">
> <input type="text" name="monkey[1].age">
>
> Somehow, these values are not populated in the form bean.
> Do I have to specify Monkey bean anywhere in struts-config?
>
> It works with simple arrays and when the nested bean is not an array,
> but it doesn't if the nested bean is an array. Am I doing something
> wrong?
>
> Regards,
> Choudary.
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>