The problem here is the need to be able to populate the form from a submission. Initialising it in the action before forwarding to the view is okay when rendering the page to the browser, but when interpreting the forms submission, struts is going to instantiate the new actionform instance (its request scoped I presume), call its reset(), and then try to populate it, before any action is invoked. The only place to initialise the size of the list so populate will work is in the reset() method, however its naughty to connect to the database (to find out the required size) from here. My first suggestion was to use a lazy list. Thats probably the best way, but another simple method would be to write the size of the list to a hidden field in the html. Then it will be sent back in the submitted request. You can then check that in the reset() method using getParameter(). ie (at its simplest), in reset() : int size = Integer.parseInt( request.getParameter("myListSize") ); this.propertyValues = new ArrayList(size); Ummm. I was having another look at that wiki link I sent. Its notable that their example provides an indexed getter. You may also need to do something like that, but I dont recall the details :-( Jeff Beal wrote: > When I have this sort of thing, I usually put it in an "initializer" > Action that I always link to in place of the JSP. > > type="com.example.InitAction"> > > > > input="" ...> > > > > -- Jeff > > Diego Manilla Suárez wrote: > >> Hi! I have a problem with form members initialization. >> >> I have this form. >> >> public class BasicContentForm extends ValidatorForm { >> >> protected java.util.List propertyValues; >> public BasicContentForm() { >> this.propertyValues = new java.util.ArrayList(); >> } >> public void setPropertyValues( java.util.List propertyValues ) { >> this.propertyValues = propertyValues; >> } public java.util.List getPropertyValues() { >> return this.propertyValues; >> } >> public Object getPropertyValue(int index) { >> return propertyValues.get(index); >> } >> public void reset(ActionMapping mapping, HttpServletRequest >> request) { >> this.propertyValues = new java.util.ArrayList(); >> } >> } >> >> And this jsp: >> >> > id="propertyValue"> >> >> >> >> The problem is that the number and type of the elements of >> propertyValues list is calculated dynamically (from the database). I >> was doing that on my Action class, but I've realized that this doesn't >> work: when I submit the form, I get an Exception at >> BeanUtils.populate, because the list is not properly initialized. If I >> can't initialize it on the reset() method (I need to access the >> database), what else can I do? >> >> Thanks in advance > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > For additional commands, e-mail: > > --------------------------------------------------------------------- To unsubscribe, e-mail: For additional commands, e-mail: