[ 
https://issues.apache.org/jira/browse/TAP5-2391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14326113#comment-14326113
 ] 

Jochen Kemnade edited comment on TAP5-2391 at 3/24/15 8:17 AM:
---------------------------------------------------------------

I can finally replicate the bug so it can be fixed :)

Okay when you have a form loop with formstate="iteration" and there is a 
serverside validation error, the last row's textfield value becomes the first 
row's textfield value.

Code to replicate bug.
{code}
    <t:form t:id="form">
        <t:errors/>
        <t:loop source="testObject.testObject2s" value="testObject2" 
formstate="iteration">
            Price <t:textfield value="testObject2.price" validate="required"/>
        </t:loop>
        <t:submit value="Submit"/>
    </t:form>
{code}
{code}
public class AjaxValidationBug {

    @Component(id = "form")
    private Form form;

    @Property
    private TestObject testObject;

    @Property
    private TestObject2 testObject2;

    @Inject
    private AjaxResponseRenderer ajaxResponseRenderer;

    public void onPrepare() {
        if (testObject == null) {
            testObject = new TestObject();

            testObject.getTestObject2s().add(new TestObject2());
            testObject.getTestObject2s().add(new TestObject2());
        }
    }

    public void onValidateFromForm() {
        for (TestObject2 testObject2 : testObject.getTestObject2s()) {
            if (testObject2.getPrice().compareTo(BigDecimal.ONE) > 0) {
                form.recordError("price must be greater than one");
            }
        }
    }

    public void onSuccessFromForm() {
        System.out.println("success");
    }

    public class TestObject {

        private List<TestObject2> testObject2s;

        private boolean confirm;

        public boolean isConfirm() {
            return confirm;
        }

        public void setConfirm(boolean confirm) {
            this.confirm = confirm;
        }

        public List<TestObject2> getTestObject2s() {
            if (testObject2s == null) {
                testObject2s = new ArrayList<>();
            }
            return testObject2s;
        }

        public void setTestObject2s(List<TestObject2> testObject2s) {
            this.testObject2s = testObject2s;
        }

    }

    public class TestObject2 {

        private BigDecimal price;

        public BigDecimal getPrice() {
            return price;
        }

        public void setPrice(BigDecimal price) {
            this.price = price;
        }

    }

}
{code}


was (Author: gchristman):
I can finally replicate the bug so it can be fixed :)

Okay when you have a form loop with formstate="iteration" and there is a 
serverside validation error, the last row's textfield value becomes the first 
row's textfield value.

Code to replicate bug.

    <t:form t:id="form">
        <t:errors/>
        <t:loop source="testObject.testObject2s" value="testObject2" 
formstate="iteration">
            Price <t:textfield value="testObject2.price" validate="required"/>
        </t:loop>
        <t:submit value="Submit"/>
    </t:form>

public class AjaxValidationBug {

    @Component(id = "form")
    private Form form;

    @Property
    private TestObject testObject;

    @Property
    private TestObject2 testObject2;

    @Inject
    private AjaxResponseRenderer ajaxResponseRenderer;

    public void onPrepare() {
        if (testObject == null) {
            testObject = new TestObject();

            testObject.getTestObject2s().add(new TestObject2());
            testObject.getTestObject2s().add(new TestObject2());
        }
    }

    public void onValidateFromForm() {
        for (TestObject2 testObject2 : testObject.getTestObject2s()) {
            if (testObject2.getPrice().compareTo(BigDecimal.ONE) > 0) {
                form.recordError("price must be greater than one");
            }
        }
    }

    public void onSuccessFromForm() {
        System.out.println("success");
    }

    public class TestObject {

        private List<TestObject2> testObject2s;

        private boolean confirm;

        public boolean isConfirm() {
            return confirm;
        }

        public void setConfirm(boolean confirm) {
            this.confirm = confirm;
        }

        public List<TestObject2> getTestObject2s() {
            if (testObject2s == null) {
                testObject2s = new ArrayList<>();
            }
            return testObject2s;
        }

        public void setTestObject2s(List<TestObject2> testObject2s) {
            this.testObject2s = testObject2s;
        }

    }

    public class TestObject2 {

        private BigDecimal price;

        public BigDecimal getPrice() {
            return price;
        }

        public void setPrice(BigDecimal price) {
            this.price = price;
        }

    }

}

> Field-specific error not shown when AJAX used
> ---------------------------------------------
>
>                 Key: TAP5-2391
>                 URL: https://issues.apache.org/jira/browse/TAP5-2391
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Geoff Callender
>            Assignee: Howard M. Lewis Ship
>            Priority: Blocker
>              Labels: 54_release_prerequisite
>             Fix For: 5.4
>
>
> Found this bug in 5.4-beta-22. I've confirmed that the bug was not present in 
> 5.4-beta-6.
> When an error is recorded with Form.recordError(Field field, String 
> errorMessage) or ValidationTracker.recordError(Field field, String 
> errorMessage) it normally is shown in the UI by decorating the field in error 
> and displaying the errorMessage below it.
> In 5.4-beta-6 and every release ever before that, that was the behaviour 
> regardless of whether the request is non-AJAX or AJAX.  
> In 5.4-beta-22, the behaviour changes when the request is AJAX: the field 
> does not display an error. That is, the field is *not* decorated and the 
> errorMessage is *not* shown with it. If your Errors component has 
> globalOnly="true", which is the norm these days, then you won't even see the 
> error message there! If you set globalOnly="false" then the message *is* 
> shown, but who would want to set globalOnly="false"???  
> Comparing the HTTP responses of beta-22 with beta-6, I see that beta-6 had an 
> extra entry in the inits, like this:  
> ["t5/core/fields:showValidationError", "firstName_8cf3108fe0ece9", "First 
> Name must not be Acme."]



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

Reply via email to