IIRC, you also need it in reset(): public class LazyListExampleForm extends ActionForm { private List actionList; public LazyListExampleForm () { initLists(); }
public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); initLists(); } private void initLists() { Factory factory = new Factory() { public Object create() { return new ActionListBean(); } }; this.actionList = ListUtils.lazyList(new ArrayList(), factory); } // Getter/setters for list omitted } - Hubert --- "Paul, R. Chip" <[EMAIL PROTECTED]> wrote: > Note: I think this is likely different in current versions of the commons > collections lib, but this works for the version we are dependent on. > > import java.util.ArrayList; > import java.util.List; > import org.apache.commons.collections.Factory; > import org.apache.commons.collections.ListUtils; > // Nonrelevant imports ommitted > > public class LazyListExampleForm extends ActionForm { > private List actionList; > > public LazyListExampleForm () > { > Factory factory = new Factory() { > public Object create() { > return new ActionListBean(); > } > }; > this.actionList = ListUtils.lazyList(new ArrayList(), > factory); > } > > // Getter/setters for list omitted > } > > -----Original Message----- > From: Mark Lowe [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 26, 2004 8:49 AM > To: Struts Users Mailing List > Subject: Re: Problem in nested tags- Very Urgent - Please Help > > > wouldn't mind an example of how to use lazy list if you have one. > > > On 26 Feb 2004, at 15:33, Paul, R. Chip wrote: > > > Or use the Commons Collections LazyList which handles this problem > > automatically. > > > > -----Original Message----- > > From: Mark Lowe [mailto:[EMAIL PROTECTED] > > Sent: Thursday, February 26, 2004 8:09 AM > > To: Struts Users Mailing List > > Subject: Re: Problem in nested tags- Very Urgent - Please Help > > > > > > shirish posted this a few times. > > > > if you're scoping to request you'll need a while loop in your > > getFoo(int index) method > > > > public class OrgManagementForm extends ActionForm { > > > > private List addressList = new ArrayList(); > > > > public Address getAddress(int index) { > > > > while(index >= addressList.size() ) { > > this.addressList.add( new Address() ); > > } > > > > return (Address) addressList.get(index); > > } > > > > bla bla. > > > > } > > > > look like it could be your problem. > > > > > > On 26 Feb 2004, at 14:57, Parthasarathy Kesavaraj wrote: > > > >> I am having an OrganzationVO inside my form-bean. > >> > >> The OrganzationVO has a collection of AddressVOs. > >> > >> I am using nested tags like this. > >> > >> > >> <nested:nest property = "orgVO"> > >> > >> <nested:text property="orgID" size="10" maxlength="10" > >> styleClass="inputmand" tabindex="" /> > >> > >> <nested:iterate id="addressid" property="addresses" indexId="index"> > >> > >> > >> <nested:text property="company1" size="30" maxlength="30" > >> styleClass="inputmand" tabindex="" /> > >> > >> </nested:iterate> > >> > >> </nested:nest> > >> > >> while submitting the form I am getting an exception like this. > >> > >> > >> 2004-02-26 18:17:08,133 [ExecuteThread: '12' for queue: > >> 'weblogic.kernel.Default'] DEBUG org.apache. > >> commons.beanutils.BeanUtils - > >> setProperty([EMAIL PROTECTED], orgVO.a > >> ddresses[0].company1, [get populated]) > >> getAddrVOAL-->[] > >> <Feb 26, 2004 6:17:08 PM IST> <Error> <HTTP> <BEA-101017> > >> <[ServletContext(id=1735147,name=gbs,conte > >> xt-path=/gbs)] Root cause of ServletException. > >> java.lang.ArrayIndexOutOfBoundsException > >> at java.lang.reflect.Array.get(Native Method) > >> at > >> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Propert > >> y > >> U > >> tils. > >> java:525) > >> at > >> org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Property > >> U > >> tils. > >> java:428) > >> at > >> org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyU > >> t > >> ils.j > >> ava:770) > >> at > >> org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.j > >> a > >> va:80 > >> 1) > >> at > >> org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881) > >> at > >> org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) > >> at > >> org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252) > >> at > >> org.apache.struts.action.RequestProcessor.processPopulate(RequestProce > >> s > >> sor.j > >> ava:821) > >> at > >> org.apache.struts.action.RequestProcessor.process(RequestProcessor.jav > >> a > >> :254) > >> at > >> com.puma.gbs.action.RequestProcessor.process(RequestProcessor.java: > >> 133) > >> at > >> org.apache.struts.action.ActionServlet.process(ActionServlet.java: > >> 1482) > >> at > >> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) > >> at > >> javax.servlet.http.HttpServlet.service(HttpServlet.java:760) > >> at > >> javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > >> at > >> weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run( > >> S > >> ervle > >> tStubImpl.jav > >> a:1053) > >> at > >> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImp > >> l > >> .java > >> :387) > >> at > >> weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) > >> at > >> weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.jav > >> a > >> :27) > >> at > >> weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction > >> . > >> run(W > >> ebAppServletC > >> ontext.java:6316) > >> at > >> weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticated > >> S > >> ubjec > >> t.java:317) > >> at > >> weblogic.security.service.SecurityManager.runAs(SecurityManager.java: > >> 118) > >> at > >> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSer > >> v > >> letCo > >> ntext.java:36 > >> 22) > >> at > >> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImp > >> l > >> .java > >> :2569) > === message truncated === __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]