Permalink
Browse files

override Tapestry.ZoneManager#processReply to work with Prototype 1.7

  • Loading branch information...
1 parent 5488194 commit 64fa5c1004657381d9cd41f4f284a5b64a5e7a23 @jochenberger jochenberger committed Mar 31, 2011
@@ -14,12 +14,57 @@
package com.howardlewisship.tapx.prototype;
+import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.json.JSONObject;
+import org.apache.tapestry5.services.Environment;
+import org.apache.tapestry5.services.MarkupRenderer;
+import org.apache.tapestry5.services.MarkupRendererFilter;
+import org.apache.tapestry5.services.PartialMarkupRenderer;
+import org.apache.tapestry5.services.PartialMarkupRendererFilter;
+import org.apache.tapestry5.services.javascript.JavaScriptSupport;
public class PrototypeModule
{
- public void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
+ public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
{
configuration.override("tapestry.scriptaculous.path", "com/howardlewisship/tapx/prototype");
}
+
+ public static void contributeMarkupRenderer(
+ final OrderedConfiguration<MarkupRendererFilter> configuration,
+ final Environment environment,
+ @Inject @Path("classpath:com/howardlewisship/tapx/prototype/tapestry-js-fixes.js") final Asset tapestryPatches) {
+ MarkupRendererFilter tapestryFixesFilter = new MarkupRendererFilter() {
+ public void renderMarkup(final MarkupWriter writer, final MarkupRenderer renderer) {
+ JavaScriptSupport javaScriptSupport = environment.peekRequired(JavaScriptSupport.class);
+ javaScriptSupport.importJavaScriptLibrary(tapestryPatches);
+ renderer.renderMarkup(writer);
+ }
+ };
+
+ configuration.add("TapestryFixes", tapestryFixesFilter, "after:RenderSupport");
+ }
+
+ public static void contributePartialMarkupRenderer(
+ final OrderedConfiguration<PartialMarkupRendererFilter> configuration,
+ final Environment environment,
+ @Inject @Path("classpath:com/howardlewisship/tapx/prototype/tapestry-js-fixes.js") final Asset tapestryPatches) {
+
+ PartialMarkupRendererFilter tapestryFixes = new PartialMarkupRendererFilter() {
+ public void renderMarkup(final MarkupWriter writer, final JSONObject reply,
+ final PartialMarkupRenderer renderer) {
+ JavaScriptSupport javaScriptSupport = environment.peekRequired(JavaScriptSupport.class);
+ javaScriptSupport.importJavaScriptLibrary(tapestryPatches);
+ renderer.renderMarkup(writer, reply);
+ }
+ };
+
+ configuration.add("TapestryFixes", tapestryFixes, "after:RenderSupport");
+
+ }
}
@@ -0,0 +1,24 @@
+Tapestry.ZoneManager.addMethods({
+ processReply : function(reply) {
+ Tapestry.loadScriptsInReply(reply, function() {
+ /*
+ * In a multi-zone update, the reply.content may be missing, in which
+ * case, leave the curent content in place. TAP5-1177
+ */
+ reply.content != undefined && this.show(reply.content);
+
+ /*
+ * zones is an object of zone ids and zone content that will be present in
+ * a multi-zone update response.
+ */
+ reply.zones && Object.keys(reply.zones).each(function(zoneId) {
+ var manager = Tapestry.findZoneManagerForZone(zoneId);
+
+ if (manager) {
+ var zoneContent = reply.zones[zoneId];
+ manager.show(zoneContent);
+ }
+ });
+ }.bind(this));
+ }
+});

0 comments on commit 64fa5c1

Please sign in to comment.