You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/03/10 11:01:22 UTC

svn commit: r921273 [1/3] - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/ajax/api/ core/src/main/java/org/apache/myfaces/tobago/webapp/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/stand...

Author: lofwyr
Date: Wed Mar 10 10:01:22 2010
New Revision: 921273

URL: http://svn.apache.org/viewvc?rev=921273&view=rev
Log:
TOBAGO-833: update to jQuery 1.4.2
 - all name in JSON and the JavaScript must be quoted in "
 - set transport type to "POST"

Added:
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/jquery/1_4_2/
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/jquery/1_4_2/jquery.js   (with props)
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/jquery/1_4_2/jquery.min.js   (with props)
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java?rev=921273&r1=921272&r2=921273&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java Wed Mar 10 10:01:22 2010
@@ -22,8 +22,6 @@ import org.apache.commons.logging.LogFac
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
-import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
-import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.VIEW_ROOT_KEY;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.EncodeAjaxCallback;
 import org.apache.myfaces.tobago.util.RequestUtils;
@@ -48,6 +46,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
+import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.VIEW_ROOT_KEY;
+
 public class AjaxResponseRenderer {
   public static final int CODE_SUCCESS = 200;
   public static final int CODE_NOT_MODIFIED = 304;
@@ -111,11 +112,11 @@ public class AjaxResponseRenderer {
     if (LOG.isDebugEnabled()) {
       LOG.debug("write ajax response for " + component);
     }
-    writer.write("{\n    ajaxId: \"");
+    writer.write("{\n    \"ajaxId\": \"");
     writer.write(clientId);
     writer.write("\",\n");
 
-    writer.write("    html: \"");
+    writer.write("    \"html\": \"");
     try {
       FacesUtils.invokeOnComponent(facesContext, facesContext.getViewRoot(), clientId, callback);
     } catch (EmptyStackException e) {
@@ -124,14 +125,14 @@ public class AjaxResponseRenderer {
     }
     writer.write("\",\n");
 
-    writer.write("    responseCode: ");
+    writer.write("    \"responseCode\": ");
     writer.write(Integer.toString(component.getAjaxResponseCode()));
 
     if (contentWriter instanceof TobagoResponseJsonWriterImpl) {
       writer.write(",\n");
-      writer.write("    script: function() {\n");
+      writer.write("    \"script\": \"function() { ");
       writer.write(((TobagoResponseJsonWriterImpl) contentWriter).getJavascript());
-      writer.write("\n    }");
+      writer.write(" }\"");
     }
     writer.write("\n  }");
   }
@@ -172,13 +173,13 @@ public class AjaxResponseRenderer {
     ensureContentTypeHeader(facesContext, charset, contentType);
 
     PrintWriter writer = getPrintWriter(facesContext);
-    writer.write("{\n  tobagoAjaxResponse: true,\n");
-    writer.write("  responseCode: ");
+    writer.write("{\n  \"tobagoAjaxResponse\": true,\n");
+    writer.write("  \"responseCode\": ");
     writer.write(reloadRequired ? Integer.toString(CODE_RELOAD_REQUIRED) : Integer.toString(CODE_SUCCESS));
 
     if (!reloadRequired) {
       writer.write(",\n");
-      writer.write("  jsfState: \"");
+      writer.write("  \"jsfState\": \"");
       saveState(facesContext, renderKit);
       writer.write("\"");
     }
@@ -187,9 +188,9 @@ public class AjaxResponseRenderer {
     int i = 0;
     for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
       writer.write(",\n");
-      writer.write("  ajaxPart_");
+      writer.write("  \"ajaxPart_");
       writer.write(Integer.toString(i++));
-      writer.write(": ");
+      writer.write("\": ");
 
       AjaxComponent component = (AjaxComponent) entry.getValue();
       if (facesContext instanceof TobagoFacesContext) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java?rev=921273&r1=921272&r2=921273&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java Wed Mar 10 10:01:22 2010
@@ -40,28 +40,31 @@ public class TobagoResponseJsonWriterImp
     this.javascriptWriter = new FastStringWriter();
   }
 
+  @Override
   public void endJavascript() throws IOException {
     javascriptMode = false;
   }
 
+  @Override
   public void startJavascript() throws IOException {
     javascriptMode = true;
   }
 
   @Override
   public void write(String string) throws IOException {
-    writeInternal(javascriptMode ? javascriptWriter : getWriter(),
-        javascriptMode ? string: AjaxUtils.encodeJavascriptString(string));
+    writeInternal(javascriptMode ? javascriptWriter : getWriter(), AjaxUtils.encodeJavascriptString(string));
   }
 
+  @Override
   public void writeJavascript(String script) throws IOException {
-    writeInternal(javascriptWriter, script);
+    writeInternal(javascriptWriter, AjaxUtils.encodeJavascriptString(script));
   }
 
   public String getJavascript() {
     return javascriptWriter.toString();
   }
 
+  @Override
   protected void startElementInternal(Writer writer, String name, UIComponent currentComponent)
       throws IOException {
     setComponent(currentComponent);
@@ -74,6 +77,7 @@ public class TobagoResponseJsonWriterImp
     setStartStillOpen(true);
   }
 
+  @Override
   protected void endElementInternal(Writer writer, String name) throws IOException {
     if (LOG.isDebugEnabled()) {
       LOG.debug("end Element: " + name);
@@ -109,6 +113,7 @@ public class TobagoResponseJsonWriterImp
     setStartStillOpen(false);
   }
 
+  @Override
   protected void closeOpenTag() throws IOException {
     if (isStartStillOpen()) {
       getWriter().write(">");
@@ -116,6 +121,7 @@ public class TobagoResponseJsonWriterImp
     }
   }
 
+  @Override
   protected void writeAttributeInternal(Writer writer, String name, String value, boolean escape)
       throws IOException {
     if (!isStartStillOpen()) {

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=921273&r1=921272&r2=921273&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Wed Mar 10 10:01:22 2010
@@ -229,9 +229,9 @@ public class PageRenderer extends PageRe
     // jquery.js and tobago.js needs to be first!
 
     int pos = 0;
-    scriptFiles.add(pos++, debugMode ? "script/jquery/1_4_1/jquery.js" : "script/jquery/1_4_1/jquery.min.js");
-    scriptFiles.add(pos++, "script/jquery/1_4_1/jquery.compat-1.3.js"); // TODO: remove after fixing AJAX
 //    scriptFiles.add(pos++, debugMode ? "script/jquery/1_3_2/jquery.js" : "script/jquery/1_3_2/jquery.min.js");
+//    scriptFiles.add(pos++, debugMode ? "script/jquery/1_4_1/jquery.js" : "script/jquery/1_4_1/jquery.min.js");
+    scriptFiles.add(pos++, debugMode ? "script/jquery/1_4_2/jquery.js" : "script/jquery/1_4_2/jquery.min.js");
     scriptFiles.add(pos++, "script/tobago.js");
     scriptFiles.add(pos++, "script/tobago-menu.js");
     scriptFiles.add(pos++, "script/theme-config.js");
@@ -477,7 +477,7 @@ public class PageRenderer extends PageRe
     writer.endElement(HtmlConstants.DIV);
 
     // write popup components
-    // beware of ConcurrentModificationException in cascating popups!
+    // beware of ConcurrentModificationException in cascading popups!
     // no foreach
     UIPopup[] popupArray = facesContext.getPopups().toArray(new UIPopup[facesContext.getPopups().size()]);
     for (UIPopup popup : popupArray) {

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js?rev=921273&r1=921272&r2=921273&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js Wed Mar 10 10:01:22 2010
@@ -123,7 +123,9 @@ Tobago.AutocompleterAjax.prototype.doUpd
       if (data.responseCode == Tobago.Updater.CODE_SUCCESS) {
         LOG.debug("doUpdate() CODE_SUCCESS");
         LOG.debug("doUpdate() data.script() : " + data.script);
-        this.suggest(data.script())
+        var updateScript;
+        eval("updateScript = " + data.script);
+        this.suggest(updateScript());
       }
       this.requestActive = false;
     }