You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/07/29 01:54:58 UTC
svn commit: r1152045 -
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java
Author: hlship
Date: Thu Jul 28 23:54:58 2011
New Revision: 1152045
URL: http://svn.apache.org/viewvc?rev=1152045&view=rev
Log:
TAP5-1421: When adding an Alert in an Ajax request, use AjaxResponseRenderer.addCallback()
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java?rev=1152045&r1=1152044&r2=1152045&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/alerts/AlertManagerImpl.java Thu Jul 28 23:54:58 2011
@@ -17,6 +17,8 @@ package org.apache.tapestry5.internal.al
import org.apache.tapestry5.alerts.*;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
+import org.apache.tapestry5.services.ajax.JavaScriptCallback;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
public class AlertManagerImpl implements AlertManager
@@ -25,13 +27,13 @@ public class AlertManagerImpl implements
private final Request request;
- private final JavaScriptSupport javaScriptSupport;
+ private final AjaxResponseRenderer ajaxResponseRenderer;
- public AlertManagerImpl(ApplicationStateManager asm, Request request, JavaScriptSupport javaScriptSupport)
+ public AlertManagerImpl(ApplicationStateManager asm, Request request, AjaxResponseRenderer ajaxResponseRenderer)
{
this.asm = asm;
this.request = request;
- this.javaScriptSupport = javaScriptSupport;
+ this.ajaxResponseRenderer = ajaxResponseRenderer;
}
public void info(String message)
@@ -51,13 +53,19 @@ public class AlertManagerImpl implements
public void alert(Duration duration, Severity severity, String message)
{
- Alert alert = new Alert(duration, severity, message);
+ final Alert alert = new Alert(duration, severity, message);
boolean ajax = request.isXHR();
if (ajax)
{
- javaScriptSupport.addInitializerCall("addAlert", alert.toJSON());
+ ajaxResponseRenderer.addCallback(new JavaScriptCallback()
+ {
+ public void run(JavaScriptSupport javascriptSupport)
+ {
+ javascriptSupport.addInitializerCall("addAlert", alert.toJSON());
+ }
+ });
}
// In Ajax mode, ony persistent alerts need to be stored for later requests (so that they can