RE: indexed properties and form help needed

2002-11-13 Thread Andy Kriger
According to the docs for DynaActionForm, you indicate a property is indexed
by putting [] after the type name. What I think is going on is that the
property is not initalized when the iterator tries to access it, thus the
'No collection found'. But I don't know how to set this up so it works
correctly. Since Struts seems to handle just about everything else, it'd
surprise me if you couldn't iterate over a dynamic form property in order to
setup inputs.

thx

-Original Message-
From: Karr, David [mailto:david.karr@;attws.com]
Sent: Wednesday, November 13, 2002 18:02
To: Struts Users Mailing List
Subject: RE: indexed properties and form help needed


At end.

> -Original Message-
> From: Andy Kriger [mailto:akriger@;greaterthanone.com]
>
> I have a DynaActionForm collecting credit card info. A user
> can enter up to
> 3 credit cards on the form. I want to collect this info in
> the text fields
> and create new CreditCard objects automatically; ideally, I
> would get a
> CreditCard[3] once the form is submitted (optionally an
> ArrayList would be
> fine). I would like to use indexed properties (right now I'm
> using hard
> coded property names), but I cannot figure out how to set this up.
>
> I am getting either a 'No collection found' error or a
> 'Cannot iterate over
> collection' error (depending on how I mess with this).
>
> What follows is rough code of what I'm trying to do.
>
> A CreditCard object has 5 fields with get/set methods for
> each: type, name,
> number, expMonth, expYear.
>
> 
> 
>  name='registrationForm'
> length='3'>
>indexed='true'>
>   
>   
>indexed='true'>
>indexed='true'>
>indexed='true'>
>indexed='true'>
> 
> 
> 
>
> 
> 
>type='my.package.CreditCard[]'/>
> 

Note that I haven't compiled or run any of this.

I would first expect my loop to look more like this:


 
  
 
 
 
 
 


I would have accessors for "name", "number", "expMonth" and "expYear" in the
CreditCard class.

At that point, I scratch my head, because I don't know how to represent
indexed properties in DynaActionForms.  With a regular ActionForm, I would
have the following in my "registrationForm" bean:

public  CreditCard getCreditCard(int index) { return
(creditCards[index]); }
public  void  setCreditCard(int index, CreditCard creditCard) {
creditCard[index] = creditCard; }
public  CreditCard[] getCreditCards() { return (creditCards); }

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>




RE: indexed properties and form help needed

2002-11-13 Thread Karr, David
At end.

> -Original Message-
> From: Andy Kriger [mailto:akriger@;greaterthanone.com]
> 
> I have a DynaActionForm collecting credit card info. A user 
> can enter up to
> 3 credit cards on the form. I want to collect this info in 
> the text fields
> and create new CreditCard objects automatically; ideally, I 
> would get a
> CreditCard[3] once the form is submitted (optionally an 
> ArrayList would be
> fine). I would like to use indexed properties (right now I'm 
> using hard
> coded property names), but I cannot figure out how to set this up.
> 
> I am getting either a 'No collection found' error or a 
> 'Cannot iterate over
> collection' error (depending on how I mess with this).
> 
> What follows is rough code of what I'm trying to do.
> 
> A CreditCard object has 5 fields with get/set methods for 
> each: type, name,
> number, expMonth, expYear.
> 
> 
> 
>  name='registrationForm'
> length='3'>
>indexed='true'>
>   
>   
>indexed='true'>
>indexed='true'>
>indexed='true'>
>indexed='true'>
> 
> 
> 
> 
> 
> 
>type='my.package.CreditCard[]'/>
> 

Note that I haven't compiled or run any of this.

I would first expect my loop to look more like this:


 
  
 
 
 
 
 


I would have accessors for "name", "number", "expMonth" and "expYear" in the 
CreditCard class.

At that point, I scratch my head, because I don't know how to represent indexed 
properties in DynaActionForms.  With a regular ActionForm, I would have the following 
in my "registrationForm" bean:

public  CreditCard getCreditCard(int index) { return (creditCards[index]); }
public  void  setCreditCard(int index, CreditCard creditCard) { creditCard[index] 
= creditCard; }
public  CreditCard[] getCreditCards() { return (creditCards); }

--
To unsubscribe, e-mail:   
For additional commands, e-mail: