You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Nicolas Bouillon (JIRA)" <ji...@apache.org> on 2015/04/30 12:16:06 UTC

[jira] [Resolved] (TAP5-2475) Form Field in Loop : on validation error all field get the same value

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

Nicolas Bouillon resolved TAP5-2475.
------------------------------------
    Resolution: Cannot Reproduce

Was fixed since, the bug is not present in 5.4-beta-31

> Form Field in Loop : on validation error all field get the same value
> ---------------------------------------------------------------------
>
>                 Key: TAP5-2475
>                 URL: https://issues.apache.org/jira/browse/TAP5-2475
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Nicolas Bouillon
>            Priority: Blocker
>              Labels: form, validation
>             Fix For: 5.4
>
>         Attachments: tapestry-test.zip
>
>
> On 5.4-beta-26.
> Given a template like this :
> {code:xml}
> <t:form t:id="form">
>         <t:errors/>
>         <t:loop source="items" value="item">
>             <div>
>                 <t:label for="field"/>
>                 <t:textfield t:id="field" value="value" label="prop:item"/>
>             </div>
>         </t:loop>
>         <div>
>             <t:submit/>
>         </div>
>     </t:form>
> {code}
> If the validation of the form fails (global validation), the page is displayed with all the field containing the same value, the last one.
> {code:title=Index.java|borderStyle=solid}
> public class Index {
>     private Map<String, String> values;
>     @Property
>     private String item;
>     public String[] getItems() {
>         return new String[]{"one", "two", "three"};
>     }
>     public void setValue(String value) {
>         if (values == null) {
>             values = new LinkedHashMap<>();
>         }
>         values.put(item, value);
>     }
>     public String getValue() {
>         if (values == null) {
>             values = new LinkedHashMap<>();
>             for (String item : getItems()) {
>                 values.put(item, item);
>             }
>         }
>         return values.get(item);
>     }
>     @Inject
>     private AlertManager alertManager;
>     @InjectComponent
>     private Form form;
>     public void onValidateFromForm() {
>         form.recordError("Purposely generated error");
>     }
>     public void onSuccessFromForm() {
>         for (Map.Entry<String, String> entry : values.entrySet()) {
>             alertManager.info(entry.getKey() + " = " + entry.getValue());
>         }
>     }
> }
> {code}
> Any help will be welcomed to guide me to provide a patch.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)