You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/09/23 17:51:48 UTC

svn commit: r1174849 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java

Author: lu4242
Date: Fri Sep 23 15:51:48 2011
New Revision: 1174849

URL: http://svn.apache.org/viewvc?rev=1174849&view=rev
Log:
MYFACES-3322 h:outputScript "name" attribute can receive query params

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java?rev=1174849&r1=1174848&r2=1174849&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java Fri Sep 23 15:51:48 2011
@@ -26,11 +26,15 @@ import javax.faces.FacesException;
 import javax.faces.application.FacesMessage;
 import javax.faces.application.ProjectStage;
 import javax.faces.application.Resource;
-import javax.faces.component.PartialStateHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
-import javax.faces.event.*;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.ListenersFor;
+import javax.faces.event.PostAddToViewEvent;
+import javax.faces.event.PreRenderViewEvent;
 import javax.faces.render.Renderer;
 import javax.faces.view.Location;
 
@@ -188,6 +192,14 @@ public class HtmlScriptRenderer extends 
         if ("".equals(resourceName)) {
             return;
         }
+        
+        String additionalQueryParams = null;
+        int index = resourceName.indexOf('?'); 
+        if (index >= 0)
+        {
+            additionalQueryParams = resourceName.substring(index + 1);
+            resourceName = resourceName.substring(0, index);
+        }
 
         Resource resource;
         if (libraryName == null) {
@@ -222,7 +234,12 @@ public class HtmlScriptRenderer extends 
 // We can't render the content type, because usually it returns "application/x-javascript"
 // and this is not compatible with IE. We should force render "text/javascript".
             writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
-            writer.writeURIAttribute(HTML.SRC_ATTR, resource.getRequestPath(), null);
+            String path = resource.getRequestPath();
+            if (additionalQueryParams != null)
+            {
+                path = path + ( (path.indexOf('?') >= 0) ? "&" : "?" ) + additionalQueryParams; 
+            }
+            writer.writeURIAttribute(HTML.SRC_ATTR, path, null);
             writer.endElement(HTML.SCRIPT_ELEM);
         }
     }