I was missing the getPackages() method :(
- Scott
Scott Van Wart wrote:
Hi all,
I'm trying to get multiple levels of indexed, nested beans working.
I've tried a variety of solutions but I keep getting xwork or ognl
exceptions. Here's what I've tried (loosely):
public class MyAction implements Action, StrutsStatics {
private List<PackageBean> packages;
public List<PackageBean> getPackages() { return this.packages; }
public List<PackageBean> setPackages( List<PackageBean> packages
) { this.packages = packages; }
}
public class PackageBean {
private List<ElementBean> elements;
public List<ElementBean> getElements() { return this.packages; }
public List<ElementBean> setElements( List<ElementBean> packages
) { this.elements = elements; }
}
public class ElementBean {
private String property1;
private String property2;
// getters and setters
}
I refer to the properties in my inputs as
"packages[0].elements[0].property1". When I POST, I get a
NullPointerException in OgnlRuntime.getField (targetClass is null).
I tried using built-in arrays (PackageBean[] and ElementBean[]) and I
get an OgnlException (source is null in setProperty( null, "property1"
)). I try initializing these to new PackageBean[0] and new
ElementBean[0] and I get IndexOutOfBoundsException.
I tried pre-populating my collections (List<...>) with a few empty
beans in both my action and PackageBean but I get the "source is null"
exception again... I also tried the getPackage( int index ) and
setPackage( int index, PackageBean pkg ) style getters and setters all
the way through (initializing the lists with empty beans as necessary)
with no success.
Am I way off on my thoughts of how nested beans and indexed properties
work?
Thanks,
Scott
---------------------------------------------------------------------
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]