You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/09/23 20:03:27 UTC
svn commit: r1174925 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5:
internal/services/ValidationDecoratorFactoryImpl.java
services/TapestryModule.java services/ValidationDecoratorFactory.java
Author: hlship
Date: Fri Sep 23 18:03:27 2011
New Revision: 1174925
URL: http://svn.apache.org/viewvc?rev=1174925&view=rev
Log:
TAP5-1339: ValidationDecorator doesn't get called when form is rendered for zone update
Added:
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/ValidationDecoratorFactory.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java?rev=1174925&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationDecoratorFactoryImpl.java Fri Sep 23 18:03:27 2011
@@ -0,0 +1,42 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ValidationDecorator;
+import org.apache.tapestry5.annotations.Path;
+import org.apache.tapestry5.internal.DefaultValidationDecorator;
+import org.apache.tapestry5.services.Environment;
+import org.apache.tapestry5.services.ValidationDecoratorFactory;
+
+public class ValidationDecoratorFactoryImpl implements ValidationDecoratorFactory
+{
+ private final Environment environment;
+
+ private final Asset spacerImage;
+
+ public ValidationDecoratorFactoryImpl(Environment environment, @Path("${tapestry.spacer-image}")
+ Asset spacerImage)
+ {
+ this.environment = environment;
+ this.spacerImage = spacerImage;
+ }
+
+ public ValidationDecorator newInstance(MarkupWriter writer)
+ {
+ return new DefaultValidationDecorator(environment, spacerImage, writer);
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1174925&r1=1174924&r2=1174925&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Fri Sep 23 18:03:27 2011
@@ -366,6 +366,7 @@ public final class TapestryModule
binder.bind(DynamicTemplateParser.class, DynamicTemplateParserImpl.class);
binder.bind(AjaxResponseRenderer.class, AjaxResponseRendererImpl.class);
binder.bind(AlertManager.class, AlertManagerImpl.class);
+ binder.bind(ValidationDecoratorFactory.class, ValidationDecoratorFactoryImpl.class);
}
// ========================================================================
@@ -1852,16 +1853,12 @@ public final class TapestryModule
* <dd>Provides {@link ClientBehaviorSupport}</dd>
* <dt>Heartbeat</dt>
* <dd>Provides {@link org.apache.tapestry5.services.Heartbeat}</dd>
- * <dt>DefaultValidationDecorator</dt>
- * <dd>Provides {@link org.apache.tapestry5.ValidationDecorator} (as an instance of
- * {@link org.apache.tapestry5.internal.DefaultValidationDecorator})</dd>
+ * <dt>ValidationDecorator</dt>
+ * <dd>Provides {@link org.apache.tapestry5.ValidationDecorator} (via {@link ValidationDecoratorFactory#newInstance(org.apache.tapestry5.MarkupWriter)})</dd>
* </dl>
*/
public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> configuration,
- @Path("${tapestry.spacer-image}")
- final Asset spacerImage,
-
@Symbol(SymbolConstants.OMIT_GENERATOR_META)
final boolean omitGeneratorMeta,
@@ -1879,6 +1876,8 @@ public final class TapestryModule
final JavaScriptStackPathConstructor javascriptStackPathConstructor,
+ final ValidationDecoratorFactory validationDecoratorFactory,
+
@Path("${tapestry.default-stylesheet}")
final Asset defaultStylesheet)
{
@@ -1986,7 +1985,7 @@ public final class TapestryModule
{
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer)
{
- ValidationDecorator decorator = new DefaultValidationDecorator(environment, spacerImage, writer);
+ ValidationDecorator decorator = validationDecoratorFactory.newInstance(writer);
environment.push(ValidationDecorator.class, decorator);
@@ -1997,12 +1996,12 @@ public final class TapestryModule
};
configuration.add("DocumentLinker", documentLinker);
- configuration.add("JavaScriptSupport", javaScriptSupport, "after:DocumentLinker");
- configuration.add("RenderSupport", renderSupport, "after:JavaScriptSupport");
- configuration.add("InjectDefaultStyleheet", injectDefaultStylesheet, "after:JavaScriptSupport");
- configuration.add("ClientBehaviorSupport", clientBehaviorSupport, "after:JavaScriptSupport");
- configuration.add("Heartbeat", heartbeat, "after:ClientBehaviorSupport");
- configuration.add("DefaultValidationDecorator", defaultValidationDecorator, "after:Heartbeat");
+ configuration.add("JavaScriptSupport", javaScriptSupport);
+ configuration.add("RenderSupport", renderSupport);
+ configuration.add("InjectDefaultStyleheet", injectDefaultStylesheet);
+ configuration.add("ClientBehaviorSupport", clientBehaviorSupport);
+ configuration.add("Heartbeat", heartbeat);
+ configuration.add("ValidationDecorator", defaultValidationDecorator);
}
/**
@@ -2020,14 +2019,13 @@ public final class TapestryModule
* <dt>Heartbeat</dt>
* <dd>Provides {@link org.apache.tapestry5.services.Heartbeat}</dd>
* <dt>DefaultValidationDecorator</dt>
- * <dd>Provides {@link org.apache.tapestry5.ValidationDecorator} (as an instance of
- * {@link org.apache.tapestry5.internal.DefaultValidationDecorator})</dd>
+ * <dt>ValidationDecorator</dt>
+ * <dd>Provides {@link org.apache.tapestry5.ValidationDecorator} (via {@link ValidationDecoratorFactory#newInstance(org.apache.tapestry5.MarkupWriter)})</dd>
* </dl>
*/
public void contributePartialMarkupRenderer(OrderedConfiguration<PartialMarkupRendererFilter> configuration,
- @Path("${tapestry.spacer-image}")
- final Asset spacerImage,
+ final ValidationDecoratorFactory validationDecoratorFactory,
final JavaScriptStackSource javascriptStackSource,
@@ -2134,7 +2132,7 @@ public final class TapestryModule
{
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer)
{
- ValidationDecorator decorator = new DefaultValidationDecorator(environment, spacerImage, writer);
+ ValidationDecorator decorator = validationDecoratorFactory.newInstance(writer);
environment.push(ValidationDecorator.class, decorator);
@@ -2145,11 +2143,11 @@ public final class TapestryModule
};
configuration.add("DocumentLinker", documentLinker);
- configuration.add("JavaScriptSupport", javascriptSupport, "after:DocumentLinker");
- configuration.add("RenderSupport", renderSupport, "after:JavaScriptSupport");
- configuration.add("ClientBehaviorSupport", clientBehaviorSupport, "after:JavaScriptSupport");
- configuration.add("Heartbeat", heartbeat, "after:ClientBehaviorSupport");
- configuration.add("DefaultValidationDecorator", defaultValidationDecorator, "after:Heartbeat");
+ configuration.add("JavaScriptSupport", javascriptSupport);
+ configuration.add("RenderSupport", renderSupport);
+ configuration.add("ClientBehaviorSupport", clientBehaviorSupport);
+ configuration.add("Heartbeat", heartbeat);
+ configuration.add("ValidationDecorator", defaultValidationDecorator);
}
/**
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java?rev=1174925&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationDecoratorFactory.java Fri Sep 23 18:03:27 2011
@@ -0,0 +1,33 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.services;
+
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ValidationDecorator;
+
+/**
+ * Creates an instance of {@link org.apache.tapestry5.ValidationDecorator} for a
+ * {@link org.apache.tapestry5.MarkupWriter}. This service is overridden in applications
+ * that do not wish to use {@link org.apache.tapestry5.internal.DefaultValidationDecorator}.
+ *
+ * @since 5.3
+ */
+public interface ValidationDecoratorFactory
+{
+ /**
+ * Creates a new decorator for the indicated writer.
+ */
+ ValidationDecorator newInstance(MarkupWriter writer);
+}