Hi! On 12/29/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > > I'm still stumped with the best way to handle cases where your nesting > goes a bit deeper than just into one list in your ActionForm (and you > want to use Request scope for your ActionForm). Yes, I know many of you > state that it means you have a complicated UI, but I've had numerous > questions come to me personally about master-detail forms where you do > edit several records from a single form, so I'm going to write up a > tutorial on it. > > For example lets assume you want to edit on a single JSP a list of > Employees - where you want to be able to edit their "name" AND "phone > numbers": > > (imagine data below in editable text fields) > > Employee Phone Numbers > -------- ------------- > John Doe 888-888-8888 > 888-111-1111 > 222-222-2222 > > Bill Boo 111-111-3333 > 444-333-3333 > > [Submit Button] > > > So we might have a List of Employee objects where Employee has: > String name; > List phoneNumbers; > > And our ActionForm bean thus has a single property: > List employees; > > Here's the problem.... in the reset method you can set a LazyList to > wrap the Employees but there is still the problem of the internal List > of phoneNumbers in each Employee. > > I was trying: > > public void reset(ActionMapping actionMapping, HttpServletRequest > httpServletRequest) { > > employees = ListUtils.lazyList(new java.util.ArrayList(), new > Factory() { > public Object create() { > return buildEmployee(); > } > }); > } > > private Employee buildEmployee() { > //This really isn't working, > //I'll still get an index out of bounds, when > //trying to set an index of the phoneNumbers list > Employee emp = new Employee(); > List phoneNumbers = ListUtils.lazyList(new java.util.ArrayList(), > new Factory() { > public Object create() { > return new String(); > } > }); > emp.setPhoneNumbers( phoneNumbers ); > return emp; > > }
I never used something like this before but I don't understand why wouldn't this actually work if you have a nested LazyList. Can we see a stack trace please? Tamas