struts indexed form elements not getting into form bean

Discussion in 'Java' started by apaeth@fortdearborn.com, Jan 6, 2006.

  1. Guest

    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
     
    , Jan 6, 2006
    #1
    1. Advertising

  2. Tim B Guest

    <> wrote in message
    news:...
    > 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
    >
     
    Tim B, Jan 7, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pavel

    struts radio indexed field

    Pavel, Sep 19, 2003, in forum: Java
    Replies:
    1
    Views:
    8,875
    Pavel
    Sep 22, 2003
  2. Thomas P. Fuller
    Replies:
    1
    Views:
    4,544
    bitbucket43
    Aug 17, 2004
  3. milkyway
    Replies:
    2
    Views:
    630
    Ryan Stewart
    Dec 26, 2004
  4. jill
    Replies:
    5
    Views:
    15,611
  5. Myriam Abramson

    XML encoding of indexed property bean

    Myriam Abramson, Nov 26, 2007, in forum: Java
    Replies:
    0
    Views:
    314
    Myriam Abramson
    Nov 26, 2007
Loading...

Share This Page