RE: dynamic indexed properties in Form bean

2003-11-10 Thread shirishchandra.sakhare
search the user archive..This has been answered many times before..

The solution is use lazyList implementation by struts or Dynamic arryList as 
implemented in my Solution..(See in the list archive)..I think that is what u have 
also said u tried..And it works..I have also answered thsi question a couple of times..

Still if u cant get it to work or have doubt, repost the question :-))

HTH.
regards,
Shirish

-Original Message-
From: Marc Dugger [mailto:[EMAIL PROTECTED]
Sent: Monday, November 10, 2003 4:56 PM
To: [EMAIL PROTECTED]
Subject: dynamic indexed properties in Form bean


I'm having trouble populating a Form bean that has an indexed (variable
size) nested bean.  I'm using an ArrayList inside the Form bean to collect
the nested properties and it's partially working.  The problem is that
because the index is variable, I don't know how to correctly size the
ArrayList.  As a result, the nested beans are being accessed by their index
inconsistently.I'm trying to dynamically grow it as getBean(int idx) is
called, but it's messy.  Does anyone have a good solution for this?  Thanks
in advance.

JSP:



























Bean fragment:

public class LiabilityForm extends ValidatorForm implements MonthlyDebts,
DispatchForm {

private ArrayList borrowerLiability = new ArrayList();
... more properties...

public BorrowerLiability[] getBorrowerLiability() {
return (BorrowerLiability[]) this.borrowerLiability.toArray(new
BorrowerLiability[0]);
}
public BorrowerLiabilityImpl getBorrowerLiability(int idx) {
BorrowerLiabilityImpl bl;
if (borrowerLiability.size() <= idx) {
borrowerLiability.ensureCapacity(idx+1);
bl = new BorrowerLiabilityImpl();
borrowerLiability.add(bl);
} else
bl = (BorrowerLiabilityImpl) borrowerLiability.get(idx);
return bl;
}
...more method ...
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



dynamic indexed properties in Form bean

2003-11-10 Thread Marc Dugger
I'm having trouble populating a Form bean that has an indexed (variable
size) nested bean.  I'm using an ArrayList inside the Form bean to collect
the nested properties and it's partially working.  The problem is that
because the index is variable, I don't know how to correctly size the
ArrayList.  As a result, the nested beans are being accessed by their index
inconsistently.I'm trying to dynamically grow it as getBean(int idx) is
called, but it's messy.  Does anyone have a good solution for this?  Thanks
in advance.

JSP:



























Bean fragment:

public class LiabilityForm extends ValidatorForm implements MonthlyDebts,
DispatchForm {

private ArrayList borrowerLiability = new ArrayList();
... more properties...

public BorrowerLiability[] getBorrowerLiability() {
return (BorrowerLiability[]) this.borrowerLiability.toArray(new
BorrowerLiability[0]);
}
public BorrowerLiabilityImpl getBorrowerLiability(int idx) {
BorrowerLiabilityImpl bl;
if (borrowerLiability.size() <= idx) {
borrowerLiability.ensureCapacity(idx+1);
bl = new BorrowerLiabilityImpl();
borrowerLiability.add(bl);
} else
bl = (BorrowerLiabilityImpl) borrowerLiability.get(idx);
return bl;
}
...more method ...
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]