struts indexed question

Discussion in 'Java' started by Tim B, Feb 1, 2006.

  1. Tim B

    Tim B Guest

    Can anyone point me to an example of using Struts indexed properties in a
    situation with a formbean contaning a list of objects, each containing a
    further list of objects, or point out if there is an error in the code
    below? I would like to be able to round-trip to the server with full
    repopulation without having to resort to doing what I did for textbox 4.

    I have the following code in a jsp

    <logic:iterate id="bean" name="myFormBeanName"
    property="beanList" type="mypackage2.OuterBean"
    scope="request" indexId="ind">

    <%-- these 2 textboxes repopulate correctly --%
    <html:text name="bean" property="label" indexed="true" />
    <html:text name="bean" property="value" indexed="true"/>

    <logic:iterate id="nestedBean" name="bean" property="nestedBeanList"
    type="mypackage2.NestedBean" indexId = "ind2" >

    <%-- textbox 3- this textbox repopulates correctly --%>
    <input type="text"

    name="bean[<%=ind.intValue()%>].nestedBean[<%=ind2.intValue()%>].beanValue"
    value="<%=nestedBean.getBeanValue()%>"/>

    <%-- textbox 3- this textbox does not repopulate correctly --%>
    <html:text name="nestedBean" property="beanValue" indexed="true"/>
    </logic:iterate>

    </logic:iterate>


    the html generated for textbox 3 is :
    <input type="text" name="bean[0].nestedBean[0].beanValue" value="foo"/>

    the html generated for textbox 4 is:
    <input type="text" name="nestedBean[0].beanValue" value="foo">
    Tim B, Feb 1, 2006
    #1
    1. Advertising

  2. Tim B

    Tim B Guest

    oops - made a typo - last textbox is textbox 4, not 3
    Tim B, Feb 1, 2006
    #2
    1. Advertising

  3. Tim B

    Tim B Guest

    "Tim B" <> wrote in message
    news:qWYDf.299205$tl.284629@pd7tw3no...
    > Can anyone point me to an example of using Struts indexed properties in a
    > situation with a formbean contaning a list of objects, each containing a
    > further list of objects, or point out if there is an error in the code
    > below?


    answering my own question here - the <html:text> tag and its kin do not
    support indexing beyond one level. So I wrote my own version that does
    Tim B, Feb 3, 2006
    #3
  4. Tim B

    rajeshseetharam

    Joined:
    Feb 5, 2008
    Messages:
    1
    what is the version boy

    whjat is the version boy
    rajeshseetharam, Feb 5, 2008
    #4
    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,856
    Pavel
    Sep 22, 2003
  2. Rode
    Replies:
    0
    Views:
    835
  3. Stratocaster
    Replies:
    1
    Views:
    3,247
    Sudsy
    Nov 11, 2004
  4. servlette

    Struts Indexed Properties

    servlette, Jun 9, 2005, in forum: Java
    Replies:
    0
    Views:
    961
    servlette
    Jun 9, 2005
  5. Indudhar
    Replies:
    1
    Views:
    2,685
    isitmeorthey
    Aug 27, 2005
Loading...

Share This Page