Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-1718

Tapestry-beanvalidator isn't validating nested DTO objects / Doesn't mark the invalid fields in the UI

    Details

      Description

      Tapestry-beanvalidator isn't validating nested objects correctly, the problem is that component parameters i.e. the TextField#value is only bound to the attribute itself but doesn't contain the full objectpath, so using a DTO like:

      class TestDTO

      { @NotNull private String firstName; @Valid private EmbeddedObject embeddedObject; ... }

      class EmbeddedObject

      { @NotNull private String lastName; ... }

      Using the TestDTO on a page in the following way:
      class MyPage{
      ...
      @Property
      private TestDTO testDTO;

      @Component(parameters =

      {"validate=testDTO"}

      )
      private Form form;

      @Component(parameters =

      {"value=testDTO.firstName"}

      )
      private TextField firstName;

      @Component(parameters =

      {"value=testDTO.embeddedObject.lastName"}

      )
      private TextField embeddedField;
      ...
      }

      Submitting the form validates all the attributes correctly (also the embedded object validation error is listed in the t:errors component) but when it comes to BeanFieldValidator only lastName is on the Environment Stack in the BeanValidationContext. As TestDTO doesn't contain the property lastName and there's no objectpath available it doesn't traverse down the objects and can't assign the correct validation error.
      The outcome is that even the property is validated correctly, there's no red-frame (css error class) on the appropriate field in the UI.

      For reference: http://tapestry.1045711.n5.nabble.com/tapestry-beanvalidation-td4921787.html

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 3819b855d24ef9a48654e33b6bdc1bcd7bba74d5 in branch refs/heads/master from Thiago H. de Paula Figueiredo
        [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=3819b855 ]

        TAP5-1718: Tapestry-beanvalidator isn't validating nested DTO objects / Doesn't mark the invalid fields in the UI

        Show
        jira-bot ASF subversion and git services added a comment - Commit 3819b855d24ef9a48654e33b6bdc1bcd7bba74d5 in branch refs/heads/master from Thiago H. de Paula Figueiredo [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=3819b855 ] TAP5-1718 : Tapestry-beanvalidator isn't validating nested DTO objects / Doesn't mark the invalid fields in the UI
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 4a5b8fc6994b0138e60f90666b55f3b54c71ecfe in tapestry-5's branch refs/heads/5.3 from Thiago H. de Paula Figueiredo
        [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=4a5b8fc ]

        Backports the fix for TAP5-1718 to 5.3.x

        Show
        jira-bot ASF subversion and git services added a comment - Commit 4a5b8fc6994b0138e60f90666b55f3b54c71ecfe in tapestry-5's branch refs/heads/5.3 from Thiago H. de Paula Figueiredo [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=4a5b8fc ] Backports the fix for TAP5-1718 to 5.3.x
        Hide
        thiagohp Thiago H. de Paula Figueiredo added a comment -

        Reopening for adding fix version.

        Show
        thiagohp Thiago H. de Paula Figueiredo added a comment - Reopening for adding fix version.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 7c9a72cfb5e2e23eaf00a36f1a01ab9186928fef in tapestry-5's branch refs/heads/master from Thiago H. de Paula Figueiredo
        [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=7c9a72c ]

        Client validation was missing validations from annotations. TAP5-1718

        Show
        jira-bot ASF subversion and git services added a comment - Commit 7c9a72cfb5e2e23eaf00a36f1a01ab9186928fef in tapestry-5's branch refs/heads/master from Thiago H. de Paula Figueiredo [ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=7c9a72c ] Client validation was missing validations from annotations. TAP5-1718
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in tapestry-trunk-freestyle #1233 (See https://builds.apache.org/job/tapestry-trunk-freestyle/1233/)
        Client validation was missing validations from annotations. TAP5-1718 (thiagohp: rev 7c9a72cfb5e2e23eaf00a36f1a01ab9186928fef)

        • tapestry-beanvalidator/src/test/webapp/NestedObjectDemo.tml
        • tapestry-beanvalidator/src/main/java/org/apache/tapestry5/internal/beanvalidator/BeanFieldValidator.java
        • tapestry-beanvalidator/src/test/java/org/example/testapp/pages/NestedObjectDemo.java
        • tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
        • tapestry-beanvalidator/src/test/webapp/Index.tml
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in tapestry-trunk-freestyle #1233 (See https://builds.apache.org/job/tapestry-trunk-freestyle/1233/ ) Client validation was missing validations from annotations. TAP5-1718 (thiagohp: rev 7c9a72cfb5e2e23eaf00a36f1a01ab9186928fef) tapestry-beanvalidator/src/test/webapp/NestedObjectDemo.tml tapestry-beanvalidator/src/main/java/org/apache/tapestry5/internal/beanvalidator/BeanFieldValidator.java tapestry-beanvalidator/src/test/java/org/example/testapp/pages/NestedObjectDemo.java tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java tapestry-beanvalidator/src/test/webapp/Index.tml

          People

          • Assignee:
            thiagohp Thiago H. de Paula Figueiredo
            Reporter:
            matt11 Matthias Melitzer
          • Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development