myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1456877 - /myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
Date Fri, 15 Mar 2013 10:45:03 GMT
Author: lofwyr
Date: Fri Mar 15 10:45:02 2013
New Revision: 1456877

URL: http://svn.apache.org/r1456877
Log:
TOBAGO-1241: Duplicate include of theme resources

Modified:
    myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=1456877&r1=1456876&r2=1456877&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
Fri Mar 15 10:45:02 2013
@@ -221,6 +221,10 @@ public class PageRenderer extends PageRe
         writeStyle(facesContext, writer, styleFile);
       }
 
+      if (!productionMode) {
+        checkDuplicates(theme.getStyleResources(productionMode), FacesContextUtils.getStyleFiles(facesContext));
+      }
+
       String icon = page.getApplicationIcon();
       if (icon != null) {
         // XXX unify with image renderer
@@ -283,6 +287,10 @@ public class PageRenderer extends PageRe
         encodeScript(facesContext, writer, scriptFile);
       }
 
+      if (!productionMode) {
+        checkDuplicates(theme.getScriptResources(productionMode), FacesContextUtils.getScriptFiles(facesContext));
+      }
+
       // focus id
       String focusId = page.getFocusId();
       if (focusId != null) {
@@ -513,6 +521,16 @@ public class PageRenderer extends PageRe
     writer.writeStyleAttribute(style);
   }
 
+  private void checkDuplicates(String[] scriptResources, Collection<String> scriptFiles)
{
+    for (String resource : scriptResources) {
+      if (scriptFiles.contains(resource)) {
+        throw new RuntimeException("The resource '" + resource + "' will be included twice!
"
+            + "The resource is in the theme list, and explicit in the page. "
+            + "Please remove it from the page!");
+      }
+    }
+  }
+
   private void writeStyle(FacesContext facesContext, TobagoResponseWriter writer, String
styleFile)
       throws IOException {
     List<String> styles = ResourceManagerUtils.getStyles(facesContext, styleFile);



Mime
View raw message