You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2007/02/12 11:28:13 UTC

svn commit: r506403 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/ajax/api/ theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/

Author: weber
Date: Mon Feb 12 02:28:12 2007
New Revision: 506403

URL: http://svn.apache.org/viewvc?view=rev&rev=506403
Log:
TOBAGO-279 (InputSuggest did not work)

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.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/AjaxPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java?view=diff&rev=506403&r1=506402&r2=506403
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java Mon Feb 12 02:28:12 2007
@@ -123,12 +123,17 @@
         StateManager.SerializedView serializedView = stateManager.saveSerializedView(facesContext);
         stateManager.writeState(facesContext, serializedView);
 
-        contentWriter.startElement(HtmlConstants.SCRIPT, null);
-        contentWriter.writeAttribute(HtmlAttributes.TYPE, "text/javascript", null);
-        contentWriter.write("Tobago.replaceJsfState(\"");
-        contentWriter.write(StringUtils.replace(StringUtils.replace(jsfState.toString(), "\"", "\\\""), "\n", ""));
-        contentWriter.write("\");");
-        contentWriter.endElement(HtmlConstants.SCRIPT);
+        String stateValue = jsfState.toString();
+        if (stateValue.length() > 0) {
+          // in case of inputSuggest jsfState.lenght is 0
+          // inputSuggest is a special case, because the form is not included in request.
+          contentWriter.startElement(HtmlConstants.SCRIPT, null);
+          contentWriter.writeAttribute(HtmlAttributes.TYPE, "text/javascript", null);
+          contentWriter.write("Tobago.replaceJsfState(\"");
+          contentWriter.write(StringUtils.replace(StringUtils.replace(stateValue, "\"", "\\\""), "\n", ""));
+          contentWriter.write("\");");
+          contentWriter.endElement(HtmlConstants.SCRIPT);
+        }
 
         writeAjaxResponse(facesContext, content.toString());
         facesContext.responseComplete();

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?view=diff&rev=506403&r1=506402&r2=506403
==============================================================================
--- 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 Mon Feb 12 02:28:12 2007
@@ -70,8 +70,13 @@
 
   onComplete: function(request) {
 //    LOG.debug("get response = " + request.responseText);
-    this.updateChoices(request.responseText);
-    this.resetWidth();
+    var responseText = request.responseText;
+    if (responseText.substring(0, Tobago.Updater.CODE_SUCCESS.length) == Tobago.Updater.CODE_SUCCESS) {
+      responseText = responseText.substring(20);
+//      LOG.debug("responseText = " + responseText);
+      this.updateChoices(responseText);
+      this.resetWidth();
+    }
   },
 
   resetWidth: function() {

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?view=diff&rev=506403&r1=506402&r2=506403
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon Feb 12 02:28:12 2007
@@ -1600,7 +1600,7 @@
       this.requests.push(req);
     } else if (!this.pageSubmited) { // AJAX case
       LOG.debug('Current ActionId = ' + this.currentActionId + ' action= ' + actionId);
-      if (this.currentActionId == actionId) {
+      if (actionId && this.currentActionId == actionId) {
         LOG.debug('Ignoring request');
         // If actionId equals currentActionId asume double request: do nothing
         return;