You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2022/06/16 08:50:00 UTC

[jira] [Updated] (WW-1189) form field tags should be able to depend on iterator tags to write their names out as indexed w/special attribute

     [ https://issues.apache.org/jira/browse/WW-1189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-1189:
------------------------------
    Fix Version/s:     (was: 6.1.0)

> form field tags should be able to depend on iterator tags to write their names out as indexed w/special attribute
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1189
>                 URL: https://issues.apache.org/jira/browse/WW-1189
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Tags
>    Affects Versions: WW 2.2.1
>            Reporter: Gabriel Zimmerman
>            Priority: Major
>
> 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? 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)