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


    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: WW 2.2.1
    • Fix Version/s: Future
    • Component/s: Plugin - Tags
    • Labels:


      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>

      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">


      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">


      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>

      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>

      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">





            • Assignee:
              gjz22 Gabriel Zimmerman
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: