myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmuel...@apache.org
Subject svn commit: r429434 - in /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax: SuggestAjaxRenderer.java inputsuggestajax/InputSuggestAjaxRenderer.java tablesuggestajax/TableSuggestAjaxRenderer.java
Date Mon, 07 Aug 2006 19:10:28 GMT
Author: gmuellan
Date: Mon Aug  7 12:10:27 2006
New Revision: 429434

URL: http://svn.apache.org/viewvc?rev=429434&view=rev
Log:
Applied patches for TOMAHAWK-468 and TOMAHAWK-236. Thanks to Peter Mahoney.

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java?rev=429434&r1=429433&r2=429434&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
Mon Aug  7 12:10:27 2006
@@ -85,4 +85,9 @@
     {
         super.decode(facesContext, component);
     }
+
+     protected String addQueryString(String url, String queryString)
+     {    	
+   	    return url + (url.indexOf("?") > 0 ? "&" : "?") + queryString;
+     }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java?rev=429434&r1=429433&r2=429434&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
Mon Aug  7 12:10:27 2006
@@ -25,6 +25,7 @@
 import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.UnicodeEncoder;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -77,8 +78,8 @@
 
         String charset = (inputSuggestAjax.getCharset() != null ? inputSuggestAjax.getCharset()
: "");
 
-        String ajaxUrl = context.getExternalContext().encodeActionURL(actionURL+"?affectedAjaxComponent="
+ clientId +
-                "&charset=" + charset + "&" + clientId + "=%{searchString}");
+        String ajaxUrl = context.getExternalContext().encodeActionURL(addQueryString(actionURL,
"affectedAjaxComponent=" + clientId +
+                "&charset=" + charset + "&" + clientId + "=%{searchString}"));
 
         ResponseWriter out = context.getResponseWriter();
 
@@ -109,12 +110,14 @@
         }
         out.endElement(HTML.INPUT_ELEM);
 
+        String escapedValue = escapeQuotes(value);
+
         out.startElement(HTML.SCRIPT_ELEM, null);
         out.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
         out.write("dojo.event.connect(window, \"onload\", function(evt) {\n"
                     + "var comboWidget = dojo.widget.byId(\""+ clientId +"\");\n"
-                    + "comboWidget.textInputNode.value = \""+ value +"\";\n"
-                    + "comboWidget.comboBoxValue.value = \""+ value +"\";\n");
+                    + "comboWidget.textInputNode.value = \""+ escapedValue +"\";\n"
+                    + "comboWidget.comboBoxValue.value = \""+ escapedValue +"\";\n");
         out.write("});\n");
         out.endElement(HTML.SCRIPT_ELEM);
     }
@@ -138,8 +141,10 @@
 
             Object item = suggestedItem.next();
 
-            buf.append("[\"").append(item.toString()).append("\",\"")
-                .append(item.toString().substring(0, 1).toUpperCase()).append("\"],");
+            String prefix = escapeQuotes(UnicodeEncoder.encode(item.toString()).substring(0,
1)).toUpperCase();
+
+            buf.append("[\"").append(UnicodeEncoder.encode(escapeQuotes(item.toString()))).append("\",\"")
+               .append(prefix).append("\"],");
         }
 
         buf.append("];");
@@ -150,6 +155,11 @@
     public void decode(FacesContext facesContext, UIComponent component)
     {
         super.decode(facesContext, component);
+    }
+
+    private String escapeQuotes(String input)
+    {
+   	    return input != null ? input.replaceAll("\"", "\\\\\"") : "";
     }
 
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java?rev=429434&r1=429433&r2=429434&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
Mon Aug  7 12:10:27 2006
@@ -119,7 +119,7 @@
         String clientId = component.getClientId(context);
         String actionURL = getActionUrl(context);
 
-        String ajaxUrl = context.getExternalContext().encodeActionURL(actionURL+"?affectedAjaxComponent="
+ clientId);
+        String ajaxUrl = context.getExternalContext().encodeActionURL(addQueryString(actionURL,
"affectedAjaxComponent=" + clientId));
 
         ResponseWriter out = context.getResponseWriter();
 



Mime
View raw message