thanks for the reply...i was busy doing something else but i will get back to you tomorrow after some testing
dz -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 05, 2002 9:59 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: collections in forms Hi, If u are displaying the screen as text fields(using html:text tag),what ever u show on screen will be retained as all the data gets resubmitted back and struts repopulates teh form again with the data. But if u are showing a read only data on screen using bean:write tag,then the data will nto be retained as bean write tag does not include parameters in request.So in this case if u want to retain the data, u should also use html:hidden for each bean write u want to retain so that when the form is submitted, the data is resent back. I am giving some sample code...GO through it.Hope it helps. ******************************************************** //Form Class import java.util.ArrayList; import java.util.List; import org.apache.struts.action.ActionForm; public class ExampleListForm extends ActionForm { //A list of Emp beans private List beanList = new ArrayList(); public List getBeanList(){ return beanList; } public void setBeanList(List list){ beanList = list; } //very imp. //give indexed access to the beans public Employee getEmployee(int index){ //very imp //when a jsp is submited , then while auto populating the form,this will ensure that // teh fporm is populated properly. if(index >= beanList.size()){ beanList.add(new Employee()); } return (Employee)beanList.get(index); } public void setEmployee(int index,Employee emp){ beanList.set(index,emp); } } *********************************************** Bean class public class Employee { private String name; private String salary; /** * Returns the name. * @return String */ public String getName() { return name; } /** * Returns the salary. * @return String */ public String getSalary() { return salary; } /** * Sets the name. * @param name The name to set */ public void setName(String name) { this.name = name; } /** * Sets the salary. * @param salary The salary to set */ public void setSalary(String salary) { this.salary = salary; } } **************************************** JSP <%@ page language="java"%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html> <html:form action="/" > <logic:iterate id="bean" name="exampleListForm" property="beanList" indexId="i"/> <html:text name="" property="<%=\"employee[\" + i \"].name\"%>"> <html:text name="" property="<%=\"employee[\" + i \"].salary\"%>"> </logic:iterate> </html:form> </html:html> *************************************************************************** -----Original Message----- From: drew.zimber [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 05, 2002 3:07 PM To: struts-user Subject: collections in forms hey all... i've used struts quite a bit now, but im not too well versed with manipulating collections in form objects. I had thought there was a way to set up your forms/pages so that if you display a collection on screen and submit back, the form in the least retains the collection in the action class (an update would be nice too, but step by step i guess). everytime i submit back to a form, the Collection comes back null. Can anyone give me some info/links/ideas on this so i dont have to rely on the session so much? thx! dz -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>