Author: hlship
Date: Mon Sep  8 12:35:55 2008
New Revision: 693214

URL: http://svn.apache.org/viewvc?rev=693214&view=rev
Log:
TAPESTRY-2643: RenderSupport should have options for including a JavaScript 
library or Stylesheet as a String URL, not just as an Asset

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/RenderSupport.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/RenderSupport.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/RenderSupport.java?rev=693214&r1=693213&r2=693214&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/RenderSupport.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/RenderSupport.java
 Mon Sep  8 12:35:55 2008
@@ -57,6 +57,16 @@
     void addScriptLink(Asset... scriptAssets);
 
     /**
+     * Adds some number of script links as strings representations of URLs.  
The scripts are passed down to the client
+     * as-is. Note that Tapestry generates relative URLs for assets because 
the base URL varies dependending on the page
+     * and its activation context; scripts added with this method will not be 
adjusted in anyway. Typically, this is
+     * used to reference a script stored outside the web application entirely.
+     *
+     * @param scriptURLs URL strings of scripts
+     */
+    void addScriptLink(String... scriptURLs);
+
+    /**
      * Used to add scripts that are stored on the classpath. Each element has 
[EMAIL PROTECTED] SymbolSource symbols
      * expanded}, then is [EMAIL PROTECTED] AssetSource converted to an asset} 
and added as a script link.
      *
@@ -77,6 +87,14 @@
     void addStylesheetLink(Asset stylesheet, String media);
 
     /**
+     * Adds a stylesheet as a URL. See notes in [EMAIL PROTECTED] 
#addScriptLink(String[])}.
+     *
+     * @param stylesheetURL URL string of stylesheet
+     * @param media         media value fo the stylesheet, or null to not 
specify a specific media type
+     */
+    void addStylesheetLink(String stylesheetURL, String media);
+
+    /**
      * Adds a script statement to the page's script block. A newline will be 
added after the script statement.
      *
      * @param script text to be added to the script block

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java?rev=693214&r1=693213&r2=693214&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
 Mon Sep  8 12:35:55 2008
@@ -108,6 +108,16 @@
         }
     }
 
+    public void addScriptLink(String... scriptURLs)
+    {
+        addCore();
+
+        for (String url : scriptURLs)
+        {
+            linker.addScriptLink(url);
+        }
+    }
+
     public void addClasspathScriptLink(String... classpaths)
     {
         addCore();
@@ -220,6 +230,12 @@
         linker.addStylesheetLink(stylesheet.toClientURL(), media);
     }
 
+
+    public void addStylesheetLink(String stylesheetURL, String media)
+    {
+        linker.addStylesheetLink(stylesheetURL, media);
+    }
+
     private void addCore()
     {
         if (!coreAssetsAdded)

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java?rev=693214&r1=693213&r2=693214&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
 Mon Sep  8 12:35:55 2008
@@ -51,6 +51,22 @@
     }
 
     @Test
+    public void add_script_link_by_url()
+    {
+        DocumentLinker linker = mockDocumentLinker();
+
+        linker.addScriptLink(ASSET_URL);
+
+        replay();
+
+        RenderSupport support = new RenderSupportImpl(linker, null, null);
+
+        support.addScriptLink(ASSET_URL);
+
+        verify();
+    }
+
+    @Test
     public void core_assets_added()
     {
         getMocksControl().checkOrder(true);
@@ -144,7 +160,7 @@
     }
 
     @Test
-    public void add_stylesheet_link()
+    public void add_stylesheet_link_by_asset()
     {
         String media = "print";
         DocumentLinker linker = mockDocumentLinker();
@@ -163,6 +179,23 @@
     }
 
     @Test
+    public void add_stylesheet_link_by_url()
+    {
+        String media = "print";
+        DocumentLinker linker = mockDocumentLinker();
+
+        linker.addStylesheetLink(ASSET_URL, media);
+
+        replay();
+
+        RenderSupport support = new RenderSupportImpl(linker, null, null);
+
+        support.addStylesheetLink(ASSET_URL, media);
+
+        verify();
+    }
+
+    @Test
     public void add_init_with_single_string_parameter()
     {
         DocumentLinker linker = mockDocumentLinker();


Reply via email to