Alex, 
This kind of behavior is pretty advanced, but it should be supported by
the type conversion. Suppose your action is FooAction, just add the
following to FooAction-conversion.properties:

Collection_rows = java.util.HashMap

Then in your HTML, you could name the elements:

rows[0]{'foo'}
rows[1]{'bar'}
rows[2]{'baz'}

Because Ognl supports this syntax for Maps, you could also name the
elements:

rows[0].foo
rows[1].bar
rows[2].baz

This technique might be nicer if you want to use a Row object. To do
that, you'd leave the "rows[0].foo" naming convention and just change
FooAction-conversion.properties to be:

Collection_rows = com.acme.Row

Patrick

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Alexandru Roman
> Sent: Tuesday, February 10, 2004 9:32 AM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] dynamic form submission
> 
> If I am generating a dynamic row based form, how can I submit the form
> elements to the action in a structured manner.
> 
> I know it is possible to submit form elements as a collection by
giving
> the fields the same name as in:
> (the same would work for multi select checkboxes)
> 
> <INPUT type="textbox" name="addField" value="field value1">
> <INPUT type="textbox" name="addField" value="field value2">
> <INPUT type="textbox" name="addField" value="field value3">
> 
> I would like to take it one step furthur and be able to submit data as
> a table with an arbitrary number of rows.
> 
> A collection of hashes would be good way. For example:
> 
> <INPUT type="textbox" name="row[0]{field1}" value="row 1 field
> value1">
> <INPUT type="textbox" name="row[0]{field2}" value="row 1 field
> value2">
> <INPUT type="textbox" name="row[0]{field3}" value="row 1 field
> value3">
> 
> <INPUT type="textbox" name="row[1]{field1}" value="row 2 field
> value1">
> <INPUT type="textbox" name="row[1]{field2}" value="row 2 field
> value2">
> <INPUT type="textbox" name="row[1]{field3}" value="row 3 field
> value3">
> 
> ...
> 
> 
> So the action would have a setter for rows:
> 
> public void setRows(Collection row) {
> 
>   //print out the rows
>   Iterator it = row.iterator();
>   while(it.hasNext()) {
>     HashMap rowData = (HashMap)it.next();
>     System.out.println(rowData.get("field1"));
>     System.out.println(rowData.get("field2"));
>     System.out.println(rowData.get("field3"));
>   }
> 
> Even better would be to map it directly to a value object for the row
> if possible
> 
> public void setRows(Collection row) {
> 
>   //print out the rows
>   Iterator it = row.iterator();
>   while(it.hasNext()) {
>     Row rowData = (Row)it.next();
>     System.out.println(rowData.getField1());
>     System.out.println(rowData.getField2());
>     System.out.println(rowData.getField3());
>   }
> 
> So in essence webworks could parse the form element name as
> "ObjectName[ObjectIndex]{FieldName}".
> 
> thanks,
> 
> Alex.
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to