struts indexed form elements not getting into form bean

A

apaeth

I'm using struts 1.2.7 and I've got what seems like should be a rather
simple task to complete. I've got a form that lists an arbitrary
number of items in rows. I'm iterating through a collection to
generate this list, so I'm using the indexed attribute on all the html
elements.

<html:form action="/DoFileStuff">
....
<logic:iterate id="file" name="folder" property="newFiles"
type="foo.FileLister">
....
<html:text name="fileStuffForm" property="extinfo" indexed="true"/>
....
</logic:iterate>
....
</html:form>

the text box gets the name "fileStuffForm[0].extinfo" which I believe
is correct. The struts config for this form looks something like this.


<form-bean name="fileStuffForm" dynamic="true" >
<form-property name="extinfo" type="java.lang.String[]" />
</form-bean>
...
<action path="/DoFileStuff"
name="fileStuffForm"
type="foo.ProcessFileRequestAction">
<forward name="success" path=".view.Files"/>
</action>

I've discovered that the property name in the DynaValidatorForm ends up
being extinfo and it shows that it contains a String[], but the array
always ends up being empty. I know that this works correctly using a
non-indexed html element and I'd just switch to getting the values
directly out of the request since I know what the name is, but I want
to be able to use the validation built into the form.

Thanks in advance for any help,
A Paeth
 
T

Tim B

I'm using struts 1.2.7 and I've got what seems like should be a rather
simple task to complete. I've got a form that lists an arbitrary
number of items in rows. I'm iterating through a collection to
generate this list, so I'm using the indexed attribute on all the html
elements.

<html:form action="/DoFileStuff">
...
<logic:iterate id="file" name="folder" property="newFiles"
type="foo.FileLister">

I had a similar problem, although not with a dynamform. The fix was to give
the id and property the same value
<html:text name="fileStuffForm" property="extinfo" indexed="true"/>
...
</logic:iterate>
...
</html:form>

the text box gets the name "fileStuffForm[0].extinfo" which I believe
is correct.

shouldn't this be fileStuffForm.extinfo[0] ?
The struts config for this form looks something like this.
<form-bean name="fileStuffForm" dynamic="true" >
<form-property name="extinfo" type="java.lang.String[]" />
</form-bean>
...
<action path="/DoFileStuff"
name="fileStuffForm"
type="foo.ProcessFileRequestAction">
<forward name="success" path=".view.Files"/>
</action>

I've discovered that the property name in the DynaValidatorForm ends up
being extinfo and it shows that it contains a String[], but the array
always ends up being empty. I know that this works correctly using a
non-indexed html element and I'd just switch to getting the values
directly out of the request since I know what the name is, but I want
to be able to use the validation built into the form.

Thanks in advance for any help,
A Paeth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top