Been a while since Ive done it, but this sort of thing can be managed using a lazy list (from commons-collections).

http://jakarta.apache.org/commons/collections/api/org/apache/commons/collections/ListUtils.html#lazyList

[http://jakarta.apache.org/commons/collections/api/org/apache/commons/collections/ListUtils.html#lazyList]

I forget the exact semantics of it but you can check the javadocs.

Some more info here:

http://wiki.apache.org/struts/StrutsCatalogLazyList

[http://wiki.apache.org/struts/StrutsCatalogLazyList]


hth Andrew

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:

<logic:iterate name="basicContentForm" property="propertyValues" id="propertyValue">
<html:text name="propertyValue" property="value" indexed="true"/>
</logic:iterate>


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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



Reply via email to