click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r779248 - /incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java
Date Wed, 27 May 2009 17:20:56 GMT
Author: sabob
Date: Wed May 27 17:20:56 2009
New Revision: 779248

URL: http://svn.apache.org/viewvc?rev=779248&view=rev
Log:
improved JsScript to skip rendering addLoadEvent for Ajax requests. CLK-517

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java?rev=779248&r1=779247&r2=779248&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/element/JsScript.java Wed May
27 17:20:56 2009
@@ -376,6 +376,9 @@
      */
     public void render(HtmlStringBuffer buffer) {
 
+        Context context = getContext();
+        boolean isAjaxRequest = context.isAjaxRequest();
+
         // Render IE conditional comment if conditional comment was set
         renderConditionalCommentPrefix(buffer);
 
@@ -391,12 +394,19 @@
         // Render CDATA tag if necessary
         renderCharacterDataPrefix(buffer);
 
-        // Render the DOM ready function prefix
-        renderDomReadyPrefix(buffer);
-
-        renderContent(buffer);
+        // Render the DOM ready function prefix for non-ajax requests. Ajax
+        // requests does not trigger DOM ready event so the prefix should not be
+        // rendered
+        if (!isAjaxRequest) {
+            renderDomReadyPrefix(buffer);
+        }
 
-        renderDomReadySuffix(buffer);
+        renderContent(buffer, context);
+
+        // Render the DOM ready function suffic for non-ajax requests
+        if (!isAjaxRequest) {
+            renderDomReadySuffix(buffer);
+        }
 
         renderCharacterDataSuffix(buffer);
 
@@ -462,10 +472,10 @@
      * to the specified buffer.
      *
      * @param buffer the buffer to append the output to
+     * @param context the request context
      */
-    protected void renderContent(HtmlStringBuffer buffer) {
+    protected void renderContent(HtmlStringBuffer buffer, Context context) {
         if (getTemplate() != null) {
-            Context context = getContext();
 
             Map templateModel = getModel();
             if (templateModel == null) {



Mime
View raw message