Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-1189

form field tags should be able to depend on iterator tags to write their names out as indexed w/special attribute

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Do
    • WW 2.2.1
    • None
    • Plugin - Tags
    • None

    Description

      It would be nice for input fields to be able to, if an attribute such as indexed="true" is set to depend on an iterator. So for example:

      <ww:iterator value="fruits">
      <ww:text name="name" indexed="true"/><br>
      <ww:text name="color" indexed="true"/><br>
      </ww:iterator>

      would generate if KeyProperty were specified (in this example as the name property):
      <input type="text" name="fruits('orange').name" value="orange">
      <input type="text" name="fruits('orange').color" value="orange">

      <input type="text" name="fruits('apple').name" value="apple">
      <input type="text" name="fruits('apple').color" value="red">

      <input type="text" name="fruits('banana').name" value="banana">
      <input type="text" name="fruits('banana'').color" value="yellow">

      etc.

      Or in the case of a List where KeyProperty is not specified:
      <input type="text" name="fruits[0].name" value="orange">
      <input type="text" name="fruits[0].color" value="orange">

      <input type="text" name="fruits[1].name" value="apple">
      <input type="text" name="fruits[1].color" value="red">

      <input type="text" name="fruits[2].name" value="banana">
      <input type="text" name="fruits[2].color" value="yellow">

      etc.

      Something also that might be helpful is to be able to add a prefix to the name, if fruits, say were a subproperty of the submitting action, so in the first example:
      <ww:iterator value="fruits">
      <ww:text name="name" indexed="true" prefix="fruitbowl."/><br>
      <ww:text name="color" indexed="true" prefix="fruitbowl."/><br>
      </ww:iterator>

      Would generate:
      <input type="text" name="fruitbowl.fruits('orange').name" value="orange">
      <input type="text" name="fruitbowl.fruits('orange').color" value="orange">

      <input type="text" name="fruitbowl.fruits('apple').name" value="apple">
      <input type="text" name="fruitbowl.fruits('apple').color" value="red">

      <input type="text" name="fruitbowl.fruits('banana').name" value="banana">
      <input type="text" name="fruitbowl.fruits('banana'').color" value="yellow">

      Now comes the hard question. What would be the ideal way to deal with nested iterators? The way I have thought of is to use another attribute called nested, which if set to true would index all previous loops. So, if we have:
      <ww:iterator value="fruitbowls">
      <ww:iterator value="fruits">
      <ww:text name="name" indexed="true" prefix="fruitbowl."/><br>
      <ww:text name="color" indexed="true" prefix="fruitbowl."/><br>
      </ww:iterator>
      </ww:iterator>

      It would generate:
      <input type="text" name="fruitbowls[0].fruits('orange').name" value="orange">
      <input type="text" name="fruitbowls[0].fruits('orange').color" value="orange">

      <input type="text" name="fruitbowls[0].fruits('apple').name" value="apple">
      <input type="text" name="fruitbowls[0].fruits('apple').color" value="red">

      <input type="text" name="fruitbowls[0].fruits('banana').name" value="banana">
      <input type="text" name="fruitbowls[0].fruits('banana'').color" value="yellow">

      <input type="text" name="fruitbowls[1].fruits('orange').name" value="orange">
      <input type="text" name="fruitbowls[1.fruits('orange').color" value="orange">

      <input type="text" name="fruitbowls[1].fruits('apple').name" value="apple">
      <input type="text" name="fruitbowls[1].fruits('apple').color" value="red">

      <input type="text" name="fruitbowls[1].fruits('banana').name" value="banana">
      <input type="text" name="fruitbowls[1].fruits('banana').color" value="yellow">

      Comments?

      Attachments

        Activity

          People

            Unassigned Unassigned
            gjz22 Gabriel Zimmerman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: