Tapestry 5
  1. Tapestry 5
  2. TAP5-1339

Provide a single extension point to provide a ValidationDecorator instance for both traditional and Ajax renders

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2.3
    • Fix Version/s: 5.3
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      I contributed a custom ValidationDecorator which works fine when the form is rendered as part of the normal page render lifecycle.
      But, if i update a zone with the same form component the ValidationDecorator doesn't get executed and as such the form doesn't get decorated.

        Activity

        Hide
        Hugo Palma added a comment -

        The problem seems to be that the inject ValidationDecorator into the Label component is not the contributed one but the default BaseValidationDecorator.

        Again, this only happens when the form is rendered by a zone update.

        Show
        Hugo Palma added a comment - The problem seems to be that the inject ValidationDecorator into the Label component is not the contributed one but the default BaseValidationDecorator. Again, this only happens when the form is rendered by a zone update.
        Hide
        Hugo Palma added a comment -

        A workaround for this:

        public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> configuration, final Environment environment) {

        MarkupRendererFilter defaultValidationDecorator = new MarkupRendererFilter() {
        public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer)

        { environment.push(ValidationDecorator.class, new MyValidatorDecorator(environment, writer)); renderer.renderMarkup(writer); environment.pop(ValidationDecorator.class); }

        };

        configuration.add("MyValidatorDecorator", defaultValidationDecorator, "after:DefaultValidationDecorator");
        }

        public void contributePartialMarkupRenderer(OrderedConfiguration<PartialMarkupRendererFilter> configuration,
        final Environment environment) {

        PartialMarkupRendererFilter defaultValidationDecorator = new PartialMarkupRendererFilter() {
        public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer)

        { environment.push(ValidationDecorator.class, new MyValidatorDecorator(environment, writer)); renderer.renderMarkup(writer, reply); environment.pop(ValidationDecorator.class); }

        };

        configuration.add("MyValidatorDecorator", defaultValidationDecorator, "after:DefaultValidationDecorator");
        }

        Still, i don't think this invalidates this issue as it should work out-of-the-box.

        Show
        Hugo Palma added a comment - A workaround for this: public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> configuration, final Environment environment) { MarkupRendererFilter defaultValidationDecorator = new MarkupRendererFilter() { public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { environment.push(ValidationDecorator.class, new MyValidatorDecorator(environment, writer)); renderer.renderMarkup(writer); environment.pop(ValidationDecorator.class); } }; configuration.add("MyValidatorDecorator", defaultValidationDecorator, "after:DefaultValidationDecorator"); } public void contributePartialMarkupRenderer(OrderedConfiguration<PartialMarkupRendererFilter> configuration, final Environment environment) { PartialMarkupRendererFilter defaultValidationDecorator = new PartialMarkupRendererFilter() { public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) { environment.push(ValidationDecorator.class, new MyValidatorDecorator(environment, writer)); renderer.renderMarkup(writer, reply); environment.pop(ValidationDecorator.class); } }; configuration.add("MyValidatorDecorator", defaultValidationDecorator, "after:DefaultValidationDecorator"); } Still, i don't think this invalidates this issue as it should work out-of-the-box.
        Hide
        Howard M. Lewis Ship added a comment -

        I've really changed this ... your problem is (I'm assuming) that you overrode Tapestry's use of DefaultValidationDecorator for traditional requests, but not for Ajax requests.

        I've introduce a new service, ValidationDecoratorFactory, that can be overridden to catch both cases.

        Show
        Howard M. Lewis Ship added a comment - I've really changed this ... your problem is (I'm assuming) that you overrode Tapestry's use of DefaultValidationDecorator for traditional requests, but not for Ajax requests. I've introduce a new service, ValidationDecoratorFactory, that can be overridden to catch both cases.
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #537 (See https://builds.apache.org/job/tapestry-trunk-freestyle/537/)
        TAP5-1339: ValidationDecorator doesn't get called when form is rendered for zone update

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1174925
        Files :

        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #537 (See https://builds.apache.org/job/tapestry-trunk-freestyle/537/ ) TAP5-1339 : ValidationDecorator doesn't get called when form is rendered for zone update hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1174925 Files : /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Hugo Palma
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development