Hi,
I have found a way of doing this but am not sure if this is the best way.
ActionForm:
I am using Vector as collection. I have put indexed getter and setter for
this vector.
This is a vector of beans (MyBean).
in JSP:
The property attribute of html:text is set to a value which is of array
format. The basic idea is when the html is generated the name of the text
field should be of format 'myVector[1].textName' so that appropriate getters
are called by struts when the html is submitted.
Here is the JSP Code,
<%int ij =0;%>
<logic:iterate id="itElement" name="myActionForm" property="myVector"
type="MyBean">
<tr>
<td >
<html:text name="myActionForm"
property="<%=\"myVector[\"+ij+\"].textName\"%>"
value="<%=itElement.getTextName() %>" />
</td>
</tr>
<% ij++;%>
</logic:iterate>
NOTE: set the scope to "session" for the cooresponding action in
struts-config.
HTH,
Vijay
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 16, 2002 10:27 AM
To: Struts Users Mailing List
Subject: RE: Retrieving set of values from html to Vector using Struts
1.0
I too have been wrestling with this.
Question:
Does the use of indexed property help this situation?
The problem is that I have no way of knowing how big my lists will be.
I know that indexed properties will help to populate a list with existing
objects,
but I would like to be able to create the list as needed.
"Tandon, Pankaj" <[EMAIL PROTECTED]> on 05/16/2002 12:05:33 PM
Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
cc:
Subject: RE: Retrieving set of values from html to Vector using Struts 1.0
I have used a getter that returns a COllection to iterate and a String[] to
write back. So in essence, you draw your cbs and text items, row by row but
you write column by column (notionally)
So in you form:
Colelction names = new ArrayList(10);
String[] nameArray = new String[10];
public Collection getNames(){return names;}
public void setNameArray(String[] s){nameArray = s;}
And in the jsp
<logic:iterate id ="aName" name="yourFormBean" property="names" >
<html:text property="nameArray"/>
</logic:iterate>
Now, nameArry shd be avlbl inthe action (via th eform). There you can place
it in a Vector or suchlike.
HTH,
Pankaj
-----Original Message-----
From: Vijay Gupta [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 16, 2002 12:30 PM
To: Struts Users Mailing List
Subject: Retrieving set of values from html to Vector using Struts 1.0
Hi,
I use struts 1.0. I am displaying a set of check boxes and textboxes from a
vector in ActionForm using Itereate tag. But when the html form is
submitted, I am unable to retrieve the same into the Vector which is an
attribute of ActionForm.
Could any one give me a solution using struts 1.0.
Thanks in advance.
Regards
VijaY
--
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]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>